/** * Returns a new <code>Map.Entry</code> object with key and value from this pair. * * @return a MapEntry instance */ public Map.Entry toMapEntry() { return new DefaultMapEntry(this); }
/** * Returns a new <code>Map.Entry</code> object with key and value from this pair. * * @return a MapEntry instance */ public Map.Entry toMapEntry() { return new DefaultMapEntry(this); }
/** * Make an instance of Map.Entry with the default (null) key and value. * Subclasses should override this method to return a Map.Entry * of the type being tested. */ public Map.Entry makeMapEntry() { return new DefaultMapEntry(null, null); }
public Object[] toArray(Object[] arr) { // special implementation to handle disappearing entries ArrayList list = new ArrayList(); Iterator iterator = iterator(); while (iterator.hasNext()) { Entry e = (Entry) iterator.next(); list.add(new DefaultMapEntry(e.getKey(), e.getValue())); } return list.toArray(arr); } }
/** * Make an instance of Map.Entry with the specified key and value. * Subclasses should override this method to return a Map.Entry * of the type being tested. */ public Map.Entry makeMapEntry(Object key, Object value) { return new DefaultMapEntry(key, value); }
public Object[] toArray(Object[] arr) { // special implementation to handle disappearing entries ArrayList list = new ArrayList(); Iterator iterator = iterator(); while (iterator.hasNext()) { Entry e = (Entry) iterator.next(); list.add(new DefaultMapEntry(e.getKey(), e.getValue())); } return list.toArray(arr); } }
public Object[] toArray(Object[] arr) { ArrayList list = new ArrayList(); Iterator iterator = iterator(); while (iterator.hasNext()) { Entry e = (Entry)iterator.next(); list.add(new DefaultMapEntry(e.getKey(), e.getValue())); } return list.toArray(arr); } };
public Object[] toArray(Object[] arr) { ArrayList list = new ArrayList(); Iterator iterator = iterator(); while (iterator.hasNext()) { Entry e = (Entry)iterator.next(); list.add(new DefaultMapEntry(e.getKey(), e.getValue())); } return list.toArray(arr); } };
/** * Subclasses should override this method. * */ public void testConstructors() { // 1. test key-value constructor Map.Entry entry = new DefaultMapEntry(key, value); assertSame(key, entry.getKey()); assertSame(value, entry.getValue()); // 2. test pair constructor KeyValue pair = new DefaultKeyValue(key, value); assertSame(key, pair.getKey()); assertSame(value, pair.getValue()); // 3. test copy constructor Map.Entry entry2 = new DefaultMapEntry(entry); assertSame(key, entry2.getKey()); assertSame(value, entry2.getValue()); // test that the objects are independent entry.setValue(null); assertSame(value, entry2.getValue()); }
new DefaultMapEntry("RED", "#FF0000"), new DefaultMapEntry("GREEN", "#00FF00"), new DefaultMapEntry("BLUE", "#0000FF") }); assertEquals(true, test.containsKey("RED"));
@SuppressWarnings("unchecked") @Test public void outboundEntrySet() throws Exception { event = CoreEvent.builder(event).message(InternalMessage.builder(event.getMessage()).addOutboundProperty("foo", "abc") .addOutboundProperty("bar", "xyz").build()).build(); Set<Map.Entry<String, Object>> entrySet = (Set<Entry<String, Object>>) evaluate("message.outboundProperties.entrySet()", event); assertEquals(2, entrySet.size()); entrySet.contains(new DefaultMapEntry("foo", "abc")); entrySet.contains(new DefaultMapEntry("bar", "xyz")); }
@Test public void testMaskedProperties() { // test nulls assertNull(PropertiesUtils.maskedPropertyValue(null)); assertNull(PropertiesUtils.maskedPropertyValue(new DefaultMapEntry(null, "value"))); assertNull(PropertiesUtils.maskedPropertyValue(new DefaultMapEntry("key", null))); // try non-masked value Map.Entry property = new DefaultMapEntry("secretname", "secret"); assertTrue("secret".equals(PropertiesUtils.maskedPropertyValue(property))); // now mask value PropertiesUtils.registerMaskedPropertyName("secretname"); String masked = PropertiesUtils.maskedPropertyValue(property); assertFalse("secret".equals(masked)); assertTrue(masked.startsWith("*")); }
@SuppressWarnings("unchecked") @Test public void inboundEntrySet() throws Exception { Message message = event.getMessage(); event = CoreEvent.builder(event) .message(InternalMessage.builder(message).addInboundProperty("foo", "abc").addInboundProperty("bar", "xyz").build()) .build(); Set<Map.Entry<String, Object>> entrySet = (Set<Entry<String, Object>>) evaluate("message.inboundProperties.entrySet()", event); assertEquals(2, entrySet.size()); entrySet.contains(new DefaultMapEntry("foo", "abc")); entrySet.contains(new DefaultMapEntry("bar", "xyz")); }
/** * Returns a new <code>Map.Entry</code> object with key and value from this pair. * * @return a MapEntry instance */ public Map.Entry toMapEntry() { return new DefaultMapEntry(this); }
/** * Returns a new <code>Map.Entry</code> object with key and value from this pair. * * @return a MapEntry instance */ public Map.Entry toMapEntry() { return new DefaultMapEntry(this); }
/** * Returns a new <code>Map.Entry</code> object with key and value from this pair. * * @return a MapEntry instance */ public Map.Entry toMapEntry() { return new DefaultMapEntry(this); }
/** * Returns a new <code>Map.Entry</code> object with key and value from this pair. * * @return a MapEntry instance */ public Map.Entry toMapEntry() { return new DefaultMapEntry(this); }
String[] descArray = {"aaa", "bbb", "ccc"}; List<String> codeList = newArrayList("111", "222", "333"); Map<String,CouponInfo> descCouponInfoMap = ImmutableMap.of("aaa", new CouponInfo("aaa", 1), "bbb", new CouponInfo("bbb", 2), "ccc", new CouponInfo("ccc", 3)); Map<String, Integer> codeCountMap = merge(asList(descArray), codeList).stream().collect(toMap(p -> p.getRight(), p -> descCouponInfoMap.get(p.getLeft()).getCount())); assertThat(codeCountMap).containsExactly(new DefaultMapEntry("111",1),new DefaultMapEntry("222",2),new DefaultMapEntry("333",3));
/** * Returns a new <code>Map.Entry</code> object with key and value from this pair. * * @return a MapEntry instance */ public Map.Entry toMapEntry() { return new DefaultMapEntry(this); }
@SuppressWarnings("unchecked") public synchronized Set<Map.Entry<Object, Object>> entrySet() { final Set<Map.Entry<Object,Object>> ret = new LinkedHashSet<>(); for (final Object key : m_linkedKeys) { ret.add(new DefaultMapEntry(key, get(key))); } return ret; }