Search in sources :

Example 16 with ClassMappingTree

use of jp.ossc.nimbus.util.ClassMappingTree in project nimbus by nimbus-org.

the class BeanJSONConverter method setEnabledPropertyNames.

/**
 * Javaオブジェクト→JSON変換時に出力するプロパティ名を設定する。<p>
 *
 * @param type 対象のクラス
 * @param names プロパティ名の配列
 */
public void setEnabledPropertyNames(Class type, String[] names) {
    if (propertyAccessTypeMap == null) {
        propertyAccessTypeMap = new ClassMappingTree();
    }
    PropertyAccessType pat = (PropertyAccessType) propertyAccessTypeMap.getValueOf(type);
    if (pat == null) {
        pat = new PropertyAccessType();
        propertyAccessTypeMap.add(type, pat);
    }
    if (names == null || names.length == 0) {
        pat.enabledPropertyNames = null;
    } else {
        if (pat.enabledPropertyNames == null) {
            pat.enabledPropertyNames = new HashSet();
        } else {
            pat.enabledPropertyNames.clear();
        }
        for (int i = 0; i < names.length; i++) {
            pat.enabledPropertyNames.add(names[i]);
        }
    }
}
Also used : ClassMappingTree(jp.ossc.nimbus.util.ClassMappingTree)

Example 17 with ClassMappingTree

use of jp.ossc.nimbus.util.ClassMappingTree in project nimbus by nimbus-org.

the class BeanFlowValidatorService method startService.

public void startService() throws Exception {
    if (beanFlowInvokerFactoryServiceName != null) {
        beanFlowInvokerFactory = (BeanFlowInvokerFactory) ServiceManagerFactory.getServiceObject(beanFlowInvokerFactoryServiceName);
    }
    if (beanFlowInvokerFactory == null) {
        throw new IllegalArgumentException("BeanFlowInvoker is null.");
    }
    final Set flowKeySet = beanFlowInvokerFactory.getBeanFlowKeySet();
    if (classMapping != null && classMapping.size() != 0) {
        classMap = new ClassMappingTree(null);
        final Iterator entries = classMapping.entrySet().iterator();
        while (entries.hasNext()) {
            final Map.Entry entry = (Map.Entry) entries.next();
            final Class clazz = Utility.convertStringToClass((String) entry.getKey());
            final String beanFlowKey = (String) entry.getValue();
            if (!flowKeySet.contains(beanFlowKey)) {
                throw new IllegalArgumentException("BeanFlow is not found : " + beanFlowKey);
            }
            classMap.add(clazz, beanFlowKey);
        }
    } else {
        if (classMap != null) {
            classMap.clear();
        }
    }
    if (conditions != null && conditions.length != 0) {
        if (conditionList != null) {
            conditionList.clear();
        } else {
            conditionList = new ArrayList();
        }
        for (int i = 0; i < conditions.length; i++) {
            final String condition = conditions[i];
            final int index = condition.lastIndexOf('=');
            if (index == 0 || index == -1 || index == condition.length() - 1) {
                throw new IllegalArgumentException("Condition is illegal : " + condition);
            }
            final String cond = condition.substring(0, index);
            final String beanFlowKey = condition.substring(index + 1);
            if (!flowKeySet.contains(beanFlowKey)) {
                throw new IllegalArgumentException("BeanFlow is not found : " + beanFlowKey);
            }
            conditionList.add(new Condition(cond, beanFlowKey));
        }
    } else {
        if (conditionList != null) {
            conditionList.clear();
        }
    }
    if (defaultBeanFlowKey != null && !flowKeySet.contains(defaultBeanFlowKey)) {
        throw new IllegalArgumentException("BeanFlow is not found : " + defaultBeanFlowKey);
    }
    if ((classMapping == null || classMapping.size() == 0) && (conditionList == null || conditionList.size() == 0) && defaultBeanFlowKey == null) {
        throw new IllegalArgumentException("BeanFlowKey is not specified.");
    }
}
Also used : ClassMappingTree(jp.ossc.nimbus.util.ClassMappingTree)

Aggregations

ClassMappingTree (jp.ossc.nimbus.util.ClassMappingTree)17 HashSet (java.util.HashSet)2 Iterator (java.util.Iterator)1 ServiceNameEditor (jp.ossc.nimbus.beans.ServiceNameEditor)1 NimbusClassLoader (jp.ossc.nimbus.core.NimbusClassLoader)1 ServiceName (jp.ossc.nimbus.core.ServiceName)1