List of usage examples for java.beans FeatureDescriptor getName
public String getName()
From source file:therian.util.BeanProperties.java
public static Set<String> getPropertyNames(ReturnProperties returnProperties, TherianContext context, Position.Readable<?> position) { List<? extends FeatureDescriptor> descriptors; // first try ELResolver: try {/*from w w w.j a v a 2s .c o m*/ descriptors = IteratorUtils .toList(context.getELResolver().getFeatureDescriptors(context, position.getValue())); } catch (Exception e) { descriptors = null; } if (CollectionUtils.isEmpty(descriptors)) { // java.beans introspection; on RT type if available, else raw position type: final Class<?> beanType; if (position.getValue() == null) { beanType = TypeUtils.getRawType(position.getType(), null); } else { beanType = position.getValue().getClass(); } try { descriptors = Arrays.asList(Introspector.getBeanInfo(beanType).getPropertyDescriptors()); } catch (IntrospectionException e1) { return Collections.emptySet(); } } final Set<String> result = new HashSet<>(); for (final FeatureDescriptor fd : descriptors) { final String name = fd.getName(); if (returnProperties == ReturnProperties.WRITABLE) { try { if (context.getELResolver().isReadOnly(context, position.getValue(), name)) { continue; } } catch (Exception e) { // if we can't even _check_ for readOnly, assume not writable: continue; } } result.add(name); } return result; }