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);
}
}
Aggregations