Example usage for org.apache.commons.collections.keyvalue DefaultMapEntry DefaultMapEntry

List of usage examples for org.apache.commons.collections.keyvalue DefaultMapEntry DefaultMapEntry

Introduction

In this page you can find the example usage for org.apache.commons.collections.keyvalue DefaultMapEntry DefaultMapEntry.

Prototype

public DefaultMapEntry(final Object key, final Object value) 

Source Link

Document

Constructs a new entry with the specified key and given value.

Usage

From source file:com.adobe.cq.wcm.core.components.internal.resource.ImageResourceWrapperTest.java

@Test
public void testBasicWrapping() {
    Map<String, Object> properties = new HashMap<String, Object>() {
        {//from www .  j  a  v  a 2  s  . c  om
            put("a", 1);
            put("b", 2);
            put(ResourceResolver.PROPERTY_RESOURCE_TYPE, "a/b/c");
        }
    };
    Resource wrappedResource = new ImageResourceWrapper(prepareResourceToBeWrapped(properties), "d/e/f");
    ArrayList<Map.Entry> keyValuePairs = new ArrayList<>();
    keyValuePairs.add(new DefaultMapEntry("a", 1));
    keyValuePairs.add(new DefaultMapEntry("b", 2));
    keyValuePairs.add(new DefaultMapEntry(ResourceResolver.PROPERTY_RESOURCE_TYPE, "d/e/f"));
    testValueMap(keyValuePairs, wrappedResource.adaptTo(ValueMap.class));
    testValueMap(keyValuePairs, wrappedResource.getValueMap());
    assertEquals("d/e/f", wrappedResource.getResourceType());
}

From source file:com.adobe.cq.wcm.core.components.internal.resource.ImageResourceWrapperTest.java

@Test
public void testWrappingWithHiddenProperties() {
    Map<String, Object> properties = new HashMap<String, Object>() {
        {/*  ww  w  .  java  2  s  .c  o m*/
            put("a", 1);
            put("b", 2);
            put(ResourceResolver.PROPERTY_RESOURCE_TYPE, "a/b/c");
        }
    };
    Resource wrappedResource = new ImageResourceWrapper(prepareResourceToBeWrapped(properties), "d/e/f",
            new ArrayList<String>() {
                {
                    add("b");
                }
            });
    ArrayList<Map.Entry> keyValuePairs = new ArrayList<>();
    keyValuePairs.add(new DefaultMapEntry("a", 1));
    keyValuePairs.add(new DefaultMapEntry(ResourceResolver.PROPERTY_RESOURCE_TYPE, "d/e/f"));
    testValueMap(keyValuePairs, wrappedResource.adaptTo(ValueMap.class));
    testValueMap(keyValuePairs, wrappedResource.getValueMap());
    assertFalse(wrappedResource.getValueMap().containsKey("b"));
    assertEquals("d/e/f", wrappedResource.getResourceType());
}

From source file:com.zuora.api.object.Dynamic.java

/**
 * Answers the name and values of the dynamic properties of this object
 * @return the dynamic properties, as string-object pairs
 *///from  w w w  .j  a  v  a 2 s .co m
public Collection<Entry<String, Object>> dynamicProperties() {
    return CollectionUtils.collect(getAny(), new Transformer() {
        public Object transform(Object input) {
            Element e = (Element) input;
            return new DefaultMapEntry(e.getLocalName(), e.getTextContent());
        }
    });
}

From source file:com.zuora.api.object.Dynamic.java

/**
 * Answers the name and values of the both static and dynamic properties of this object
 * @return this object's properties, as string-object pairs
 *///from   www.  j  a v a 2s .c  o  m
private Collection<Entry<String, Object>> propertyValues() {
    try {
        return collect(Arrays.asList(Introspector.getBeanInfo(this.getClass()).getPropertyDescriptors()),
                new Transformer() {
                    public Object transform(Object input) {
                        PropertyDescriptor p = (PropertyDescriptor) input;
                        return new DefaultMapEntry(p.getName(), NaiveProperties.get(Dynamic.this, p.getName()));
                    }
                });
    } catch (Exception e) {
        throw MuleSoftException.soften(e);
    }
}

From source file:net.sourceforge.vulcan.spring.jdbc.DependencyQuery.java

@Override
@SuppressWarnings("unchecked")
protected Entry<String, UUID> mapRow(ResultSet rs, int rowNumber) throws SQLException {
    return new DefaultMapEntry(rs.getString("name"), UUID.fromString(rs.getString("uuid")));
}

From source file:org.eclipse.smarthome.automation.module.script.defaultscope.internal.ItemRegistryDelegate.java

@SuppressWarnings("unchecked")
@Override//  www  .  ja v a  2s.  co  m
public Set<java.util.Map.Entry<String, State>> entrySet() {
    Set<Map.Entry<String, State>> entries = new HashSet<Map.Entry<String, State>>();
    for (Item item : itemRegistry.getAll()) {
        entries.add(new DefaultMapEntry(item.getName(), item.getState()));
    }
    return entries;
}

From source file:org.kuali.kra.proposaldevelopment.rules.KeyPersonnelAuditRule.java

/**
 * Convenience method for creating a <code>{@link SimpleEntry}</code> out of a key/value pair
 * /*from   w  w w  .j a v a  2 s .c  o m*/
 * @param key
 * @param value
 * @return SimpleImmutableEntry
 */
private Entry<String, String> keyValue(String key, String value) {
    return new DefaultMapEntry(key, value);
}

From source file:org.kuali.kra.rules.ResearchDocumentRuleBase.java

/**
 * Convenience method for creating a <code>{@link SimpleEntry}</code> out of a key/value pair
 * //w  w  w .  ja  v  a 2s .c  o m
 * @param key
 * @param value
 * @return SimpleImmutableEntry
 */
protected Entry<String, String> keyValue(String key, Object value) {

    @SuppressWarnings("unchecked") //Commons Collections does not support Generics
    final Entry<String, String> entry = (value == null) ? new DefaultMapEntry(key, "")
            : new DefaultMapEntry(key, value.toString());

    return entry;
}

From source file:org.mule.el.context.AbstractMapContext.java

@SuppressWarnings("unchecked")
@Override/*from w w  w. ja  v a2  s.  c o m*/
public Set<java.util.Map.Entry<K, V>> entrySet() {
    Set<java.util.Map.Entry<K, V>> entrySet = new HashSet<java.util.Map.Entry<K, V>>();
    for (K key : keySet()) {
        entrySet.add(new DefaultMapEntry(key, get(key)));
    }
    return entrySet;
}

From source file:org.mule.el.context.MessageAttachmentsTestCase.java

@SuppressWarnings("unchecked")
@Test/*from www. ja v  a  2 s  .  c  om*/
public void inboundEntrySet() throws Exception {
    DefaultMuleMessage message = new DefaultMuleMessage("", muleContext);
    DataHandler valA = Mockito.mock(DataHandler.class);
    DataHandler valB = Mockito.mock(DataHandler.class);
    message.addInboundAttachment("foo", valA);
    message.addInboundAttachment("bar", valB);
    Set<Map.Entry<String, DataHandler>> entrySet = (Set<Entry<String, DataHandler>>) evaluate(
            "message.inboundAttachments.entrySet()", message);
    assertEquals(2, entrySet.size());
    entrySet.contains(new DefaultMapEntry("foo", valA));
    entrySet.contains(new DefaultMapEntry("bar", valB));
}