/** * Gets bean configuration. * * @param ctx Spring context. * @param beanCls Bean class. * @return Spring bean. */ @Nullable private static <T> T bean(ListableBeanFactory ctx, Class<T> beanCls) { Map.Entry<String, T> entry = F.firstEntry(ctx.getBeansOfType(beanCls)); return entry == null ? null : entry.getValue(); }
Map.Entry<?, ?> e = F.firstEntry((Map<?, ?>)obj);
/** * @throws Exception If failed. */ @Test public void testMapEntry() throws Exception { Map.Entry<Integer, String> e = new GridMapEntry<>(1, "str1"); assertEquals(e, marshalUnmarshal(e)); Map<Integer, String> map = new HashMap<>(1); map.put(2, "str2"); e = F.firstEntry(map); Map.Entry<Integer, String> e0 = marshalUnmarshal(e); assertEquals(2, e0.getKey().intValue()); assertEquals("str2", e0.getValue()); }
/** * JUnit. */ @Test public void testGridTuple2AsMap() { String str1 = "A test string 1"; String str2 = "A test string 2"; IgniteBiTuple<String, String> tpl = new IgniteBiTuple<>(); tpl.put(str1, str2); assertEquals(str2, tpl.get(str1)); assertEquals(1, tpl.size()); assert tpl.containsKey(str1); assert tpl.containsValue(str2); Iterator<Map.Entry<String, String>> it = tpl.entrySet().iterator(); assert it.hasNext(); Map.Entry<String, String> next = it.next(); assertEquals(str1, next.getKey()); assertEquals(str2, next.getValue()); assert !it.hasNext(); next = F.firstEntry(tpl); assertEquals(str1, next.getKey()); assertEquals(str2, next.getValue()); tpl = new IgniteBiTuple<>(); assert !tpl.entrySet().iterator().hasNext(); }
/** * Gets bean configuration. * * @param ctx Spring context. * @param beanCls Bean class. * @return Spring bean. */ @Nullable private static <T> T bean(ListableBeanFactory ctx, Class<T> beanCls) { Map.Entry<String, T> entry = F.firstEntry(ctx.getBeansOfType(beanCls)); return entry == null ? null : entry.getValue(); }
Map.Entry<?, ?> e = F.firstEntry((Map<?, ?>)obj);