@Override public void introspect(IntrospectionContext icontext) throws IntrospectionException { for (Method m : icontext.getTargetClass().getMethods()) { if (m.getName().startsWith(getWriteMethodPrefix())) { String propertyName = propertyName(m); PropertyDescriptor pd = icontext.getPropertyDescriptor(propertyName); if (isIgnored(icontext.getTargetClass().getName(), m.getName())) { logger.trace(m.getName() + " Ignored for " + icontext.getTargetClass().getName()); continue; } try { if (pd == null) { icontext.addPropertyDescriptor(createFluentPropertyDescritor(m, propertyName)); } else if (pd.getWriteMethod() == null) { pd.setWriteMethod(m); } } catch (IntrospectionException e) { logger.debug(e.getMessage(), e); } } } }
/** * Performs introspection of a specific Java class. This implementation uses * the {@code java.beans.Introspector.getBeanInfo()} method to obtain * all property descriptors for the current class and adds them to the * passed in introspection context. * * @param icontext the introspection context */ public void introspect(final IntrospectionContext icontext) { BeanInfo beanInfo = null; try { beanInfo = Introspector.getBeanInfo(icontext.getTargetClass()); } catch (final IntrospectionException e) { // no descriptors are added to the context log.error( "Error when inspecting class " + icontext.getTargetClass(), e); return; } PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors(); if (descriptors == null) { descriptors = new PropertyDescriptor[0]; } handleIndexedPropertyDescriptors(icontext.getTargetClass(), descriptors); icontext.addPropertyDescriptors(descriptors); }
/** * {@inheritDoc} This implementation removes all properties from the given context it * is configured for. */ public void introspect(final IntrospectionContext icontext) throws IntrospectionException { for (final String property : getSuppressedProperties()) { icontext.removePropertyDescriptor(property); } } }
/** * Performs introspection. This method scans the current class's methods for * property write methods which have not been discovered by default * introspection. * * @param icontext the introspection context * @throws IntrospectionException if an error occurs */ public void introspect(final IntrospectionContext icontext) throws IntrospectionException { for (final Method m : icontext.getTargetClass().getMethods()) { if (m.getName().startsWith(getWriteMethodPrefix())) { final String propertyName = propertyName(m); final PropertyDescriptor pd = icontext .getPropertyDescriptor(propertyName); try { if (pd == null) { icontext.addPropertyDescriptor(createFluentPropertyDescritor( m, propertyName)); } else if (pd.getWriteMethod() == null) { pd.setWriteMethod(m); } } catch (final IntrospectionException e) { log.info("Error when creating PropertyDescriptor for " + m + "! Ignoring this property."); log.debug("Exception is:", e); } } } }
/** * Performs introspection of a specific Java class. This implementation uses * the {@code java.beans.Introspector.getBeanInfo()} method to obtain * all property descriptors for the current class and adds them to the * passed in introspection context. * * @param icontext the introspection context */ public void introspect(final IntrospectionContext icontext) { BeanInfo beanInfo = null; try { beanInfo = Introspector.getBeanInfo(icontext.getTargetClass()); } catch (final IntrospectionException e) { // no descriptors are added to the context log.error( "Error when inspecting class " + icontext.getTargetClass(), e); return; } PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors(); if (descriptors == null) { descriptors = new PropertyDescriptor[0]; } handleIndexedPropertyDescriptors(icontext.getTargetClass(), descriptors); icontext.addPropertyDescriptors(descriptors); }
/** * {@inheritDoc} This implementation removes all properties from the given context it * is configured for. */ public void introspect(final IntrospectionContext icontext) throws IntrospectionException { for (final String property : getSuppressedProperties()) { icontext.removePropertyDescriptor(property); } } }
/** * Performs introspection. This method scans the current class's methods for * property write methods which have not been discovered by default * introspection. * * @param icontext the introspection context * @throws IntrospectionException if an error occurs */ public void introspect(final IntrospectionContext icontext) throws IntrospectionException { for (final Method m : icontext.getTargetClass().getMethods()) { if (m.getName().startsWith(getWriteMethodPrefix())) { final String propertyName = propertyName(m); final PropertyDescriptor pd = icontext .getPropertyDescriptor(propertyName); try { if (pd == null) { icontext.addPropertyDescriptor(createFluentPropertyDescritor( m, propertyName)); } else if (pd.getWriteMethod() == null) { pd.setWriteMethod(m); } } catch (final IntrospectionException e) { log.info("Error when creating PropertyDescriptor for " + m + "! Ignoring this property."); log.debug("Exception is:", e); } } } }
/** * Performs introspection of a specific Java class. This implementation uses * the {@code java.beans.Introspector.getBeanInfo()} method to obtain * all property descriptors for the current class and adds them to the * passed in introspection context. * * @param icontext the introspection context */ public void introspect(final IntrospectionContext icontext) { BeanInfo beanInfo = null; try { beanInfo = Introspector.getBeanInfo(icontext.getTargetClass()); } catch (final IntrospectionException e) { // no descriptors are added to the context log.error( "Error when inspecting class " + icontext.getTargetClass(), e); return; } PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors(); if (descriptors == null) { descriptors = new PropertyDescriptor[0]; } handleIndexedPropertyDescriptors(icontext.getTargetClass(), descriptors); icontext.addPropertyDescriptors(descriptors); }
/** * {@inheritDoc} This implementation removes all properties from the given context it * is configured for. */ public void introspect(final IntrospectionContext icontext) throws IntrospectionException { for (final String property : getSuppressedProperties()) { icontext.removePropertyDescriptor(property); } } }
private static class BooleanIntrospector implements BeanIntrospector{ @Override public void introspect(IntrospectionContext icontext) throws IntrospectionException { for (Method m : icontext.getTargetClass().getMethods()) { if (m.getName().startsWith("is") && Boolean.class.equals(m.getReturnType())) { String propertyName = getPropertyName(m); PropertyDescriptor pd = icontext.getPropertyDescriptor(propertyName); if (pd == null) icontext.addPropertyDescriptor(new PropertyDescriptor(propertyName, m, getWriteMethod(icontext.getTargetClass(), propertyName))); else if (pd.getReadMethod() == null) pd.setReadMethod(m); } } } private String getPropertyName(Method m){ return WordUtils.uncapitalize(m.getName().substring(2, m.getName().length())); } private Method getWriteMethod(Class<?> clazz, String propertyName){ try { return clazz.getMethod("get" + WordUtils.capitalize(propertyName)); } catch (NoSuchMethodException e) { return null; } } }
@Override public void introspect(IntrospectionContext icontext) throws IntrospectionException { for (Method m : icontext.getTargetClass().getMethods()) { if (m.getName().startsWith(getWriteMethodPrefix())) { String propertyName = propertyName(m); PropertyDescriptor pd = icontext.getPropertyDescriptor(propertyName); if (isIgnored(icontext.getTargetClass().getName(), m.getName())) { logger.trace(m.getName() + " Ignored for " + icontext.getTargetClass().getName()); continue; } try { if (pd == null) { icontext.addPropertyDescriptor(createFluentPropertyDescritor(m, propertyName)); } else if (pd.getWriteMethod() == null) { pd.setWriteMethod(m); } } catch (IntrospectionException e) { logger.debug(e.getMessage(), e); } } } }
@Override public void introspect(IntrospectionContext icontext) throws IntrospectionException { for (Method m : icontext.getTargetClass().getMethods()) { if (m.getName().startsWith(getWriteMethodPrefix())) { String propertyName = propertyName(m); PropertyDescriptor pd = icontext.getPropertyDescriptor(propertyName); if (isIgnored(icontext.getTargetClass().getName(), m.getName())) { logger.trace(m.getName() + " Ignored for " + icontext.getTargetClass().getName()); continue; } try { if (pd == null) { icontext.addPropertyDescriptor(createFluentPropertyDescritor(m, propertyName)); } else if (pd.getWriteMethod() == null) { pd.setWriteMethod(m); } } catch (IntrospectionException e) { logger.debug(e.getMessage(), e); } } } }
@Override public void introspect(IntrospectionContext icontext) throws IntrospectionException { for (Method m : icontext.getTargetClass().getMethods()) { if (m.getName().startsWith(getWriteMethodPrefix())) { String propertyName = propertyName(m); PropertyDescriptor pd = icontext.getPropertyDescriptor(propertyName); if (isIgnored(icontext.getTargetClass().getName(), m.getName())) { logger.trace(m.getName() + " Ignored for " + icontext.getTargetClass().getName()); continue; } try { if (pd == null) { icontext.addPropertyDescriptor(createFluentPropertyDescritor(m, propertyName)); } else if (pd.getWriteMethod() == null) { pd.setWriteMethod(m); } } catch (IntrospectionException e) { logger.debug(e.getMessage(), e); } } } }
/** * Performs introspection. This method scans the current class's methods for * property write methods which have not been discovered by default * introspection. * * @param icontext the introspection context * @throws IntrospectionException if an error occurs */ public void introspect(final IntrospectionContext icontext) throws IntrospectionException { for (final Method m : icontext.getTargetClass().getMethods()) { if (m.getName().startsWith(getWriteMethodPrefix())) { final String propertyName = propertyName(m); final PropertyDescriptor pd = icontext .getPropertyDescriptor(propertyName); try { if (pd == null) { icontext.addPropertyDescriptor(createFluentPropertyDescritor( m, propertyName)); } else if (pd.getWriteMethod() == null) { pd.setWriteMethod(m); } } catch (final IntrospectionException e) { log.info("Error when creating PropertyDescriptor for " + m + "! Ignoring this property."); log.debug("Exception is:", e); } } } }