Example usage for org.apache.commons.beanutils BeanMap containsKey

List of usage examples for org.apache.commons.beanutils BeanMap containsKey

Introduction

In this page you can find the example usage for org.apache.commons.beanutils BeanMap containsKey.

Prototype

public boolean containsKey(Object name) 

Source Link

Document

Returns true if the bean defines a property with the given name.

Usage

From source file:de.iteratec.iteraplan.businesslogic.exchange.common.vbb.impl.util.VisualVariableHelper.java

/**
 * Sets the value of a given visual variable to a beanMap. If no such variable exists or the variable is null, then no value is set.
 * @param target the beanMap to which the variable should be set.
 * @param source the instance holding the values of the visual variables.
 * @param vv the visual variable to set to the beanMap.
 *///from w  w  w . j a v a 2 s  . c om
@SuppressWarnings("unchecked")
public static void setVisualVariableValue(BeanMap target, EObject source, EAttribute vv) {
    if (source.eIsSet(vv) && source.eGet(vv) != null && target.containsKey(vv.getName())) {
        Object value = source.eGet(vv);
        //TODO handle multivalued attributes here
        if (vv.getEAttributeType() instanceof EEnum) {
            Class<Enum<?>> enumType = (Class<Enum<?>>) ((EEnum) vv.getEAttributeType()).getInstanceClass();
            for (Enum<?> ec : enumType.getEnumConstants()) {
                if (ec.name().equals(((EEnumLiteral) value).getName())) {
                    value = ec;
                }
            }
        }
        target.put(vv.getName(), value);
    }
}

From source file:org.ms123.common.data.JdoLayerImpl.java

private void setRelatedToFields(Map targetMap, String[] colNames, BeanMap beanMap, Object value) {
    BeanMap relatedTo = new BeanMap(value);
    Iterator<String> it = relatedTo.keySet().iterator();
    while (it.hasNext()) {
        String key = it.next();//from   ww w.j  a  v a  2 s .  c o m
        if (key.startsWith("_"))
            continue;
        if (key.equals("class"))
            continue;
        if (key.equals("id"))
            continue;
        if (key.equals("name"))
            continue;
        if (colNames != null && !arrayContains(colNames, key))
            continue;
        if (beanMap != null && !beanMap.containsKey(key))
            continue;
        Class type = relatedTo.getType(key);
        if (type.equals(List.class) || type.equals(Set.class))
            continue;
        debug("\tsetRelatedToFields.key:" + key + "=" + relatedTo.get(key) + "/" + relatedTo.getType(key));
        targetMap.put(key, relatedTo.get(key));
    }
}