Search in sources :

Example 6 with SmartType

use of com.twinsoft.convertigo.beans.steps.SmartType in project convertigo by convertigo.

the class CachedIntrospector method getPropertyDescriptors.

public static Set<PropertyDescriptor> getPropertyDescriptors(Class<? extends DatabaseObject> beanClass, Property property) {
    try {
        Map<Property, Set<PropertyDescriptor>> beanProperties = cacheProperties.get(beanClass);
        if (beanProperties == null) {
            cacheProperties.put(beanClass, beanProperties = new WeakHashMap<Property, Set<PropertyDescriptor>>());
        }
        Set<PropertyDescriptor> propertyDescriptors = beanProperties.get(property);
        if (propertyDescriptors == null) {
            BeanInfo beanInfo = getBeanInfo(beanClass);
            for (PropertyDescriptor propertyDescriptor : beanInfo.getPropertyDescriptors()) {
                boolean add = false;
                switch(property) {
                    case sourceDefinition:
                        add = "sourceDefinition".equals(propertyDescriptor.getName());
                        break;
                    case sourcesDefinition:
                        add = "sourcesDefinition".equals(propertyDescriptor.getName());
                        break;
                    case smartType:
                        add = propertyDescriptor.getPropertyType().equals(SmartType.class);
                        break;
                }
                if (add) {
                    if (propertyDescriptors == null) {
                        propertyDescriptors = new HashSet<PropertyDescriptor>();
                    }
                    propertyDescriptors.add(propertyDescriptor);
                }
            }
            if (propertyDescriptors == null) {
                beanProperties.put(property, propertyDescriptors = GenericUtils.<Set<PropertyDescriptor>>cast(Collections.EMPTY_SET));
            } else {
                beanProperties.put(property, propertyDescriptors = Collections.unmodifiableSet(propertyDescriptors));
            }
        }
        return propertyDescriptors;
    } catch (IntrospectionException e) {
        throw new RuntimeException("Failed to getPropertyDescriptors for " + beanClass, e);
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) PropertyDescriptor(java.beans.PropertyDescriptor) BeanInfo(java.beans.BeanInfo) IntrospectionException(java.beans.IntrospectionException) SmartType(com.twinsoft.convertigo.beans.steps.SmartType) WeakHashMap(java.util.WeakHashMap)

Aggregations

SmartType (com.twinsoft.convertigo.beans.steps.SmartType)6 XMLVector (com.twinsoft.convertigo.beans.common.XMLVector)4 EngineException (com.twinsoft.convertigo.engine.EngineException)3 ObjectWithSameNameException (com.twinsoft.convertigo.engine.ObjectWithSameNameException)3 IntrospectionException (java.beans.IntrospectionException)3 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)2 DatabaseObjectNotFoundException (com.twinsoft.convertigo.engine.DatabaseObjectNotFoundException)2 UndefinedSymbolsException (com.twinsoft.convertigo.engine.UndefinedSymbolsException)2 VersionException (com.twinsoft.convertigo.engine.VersionException)2 PropertyDescriptor (java.beans.PropertyDescriptor)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 HashSet (java.util.HashSet)2 HtmlConnector (com.twinsoft.convertigo.beans.connectors.HtmlConnector)1 IXPathable (com.twinsoft.convertigo.beans.core.IXPathable)1 RequestableObject (com.twinsoft.convertigo.beans.core.RequestableObject)1 HtmlScreenClass (com.twinsoft.convertigo.beans.screenclasses.HtmlScreenClass)1 XpathableStatement (com.twinsoft.convertigo.beans.statements.XpathableStatement)1 CompositeEvent (com.twinsoft.convertigo.eclipse.editors.CompositeEvent)1 MobileSmartSourcePropertyDescriptor (com.twinsoft.convertigo.eclipse.property_editors.MobileSmartSourcePropertyDescriptor)1 NgxSmartSourcePropertyDescriptor (com.twinsoft.convertigo.eclipse.property_editors.NgxSmartSourcePropertyDescriptor)1