public static <T> void findBooleanIsMethods(Class<T> clazz, PropertyDescriptor descriptor) throws IntrospectionException { if (descriptor.getReadMethod() == null && descriptor.getPropertyType() == Boolean.class) { try { PropertyDescriptor pd = new PropertyDescriptor(descriptor.getName(), clazz); descriptor.setReadMethod(pd.getReadMethod()); } catch (IntrospectionException e) { } } }
try { if (existingPropDescriptor.getReadMethod() == null) { existingPropDescriptor.setReadMethod(superPropDescriptor.getReadMethod());
existingPD.setReadMethod(readMethod); } catch (IntrospectionException ex) { existingPD.setReadMethod(readMethod); pd.setReadMethod(readMethod); try { pd.setWriteMethod(writeMethod);
public synchronized void setReadMethod(Method readMethod) throws IntrospectionException { this.readMethod = readMethod; if( propertyDescriptor==null )return; propertyDescriptor.setReadMethod(readMethod); } //</editor-fold>
@Override public synchronized void setReadMethod(Method readMethod) throws IntrospectionException { if (this.property != null) { this.property.setReadMethod(readMethod); } }
public void setReadMethod( Method getter ) throws IntrospectionException { super.setReadMethod( getter ); if( _propertyClass == null ) { _propertyClass = super.getPropertyType(); } }
public void setReadMethod( Method getter ) throws IntrospectionException { super.setReadMethod( getter ); if( _propertyClass == null ) { _propertyClass = super.getPropertyType(); } }
private Condition<PropertyDescriptor> propertyOn(T bean, Description mismatch) { PropertyDescriptor property = PropertyUtil.getPropertyDescriptor(propertyName, bean); if (property != null) { if (property.getReadMethod() == null && property.getPropertyType().equals(Boolean.class)) { String booleanGetter = "is" propertyName.substring(0, 1).toUpperCase() propertyName.substring(1); for(Method method : bean.getClass().getDeclaredMethods()) { if (method.getName().equals(booleanGetter)) { try { property.setReadMethod(method); } catch (IntrospectionException e) { throw new IllegalStateException("Cannot set read method" e); } } } } } else { mismatch.appendText("No property \"" + propertyName + "\""); return notMatched(); } return matched(property, mismatch); }
protected Method getReadMethod(Class clazz, PropertyDescriptor pd) { Method mth = pd.getReadMethod(); if (mth == null && pd.getPropertyType() == Boolean.class) { String name = pd.getName(); name = name.substring(0, 1).toUpperCase() + name.substring(1); name = "is" + name; try { mth = clazz.getMethod(name, new Class[0]); if (mth != null) { pd.setReadMethod(mth); } } catch (IntrospectionException e) { // do nothing } catch (NoSuchMethodException e) { // do nothing } } return mth; }
readMethod = clazz.getMethod("get" + name.substring(0, 1).toUpperCase() + name.substring(1)); descriptor.setReadMethod(readMethod); } catch (NoSuchMethodException | SecurityException e) {
readMethod = clazz.getMethod("get" + name.substring(0, 1).toUpperCase() + name.substring(1)); descriptor.setReadMethod(readMethod); } catch (NoSuchMethodException | SecurityException e) {
readMethod = clazz.getMethod("get" + name.substring(0, 1).toUpperCase() + name.substring(1)); descriptor.setReadMethod(readMethod); } catch (NoSuchMethodException | SecurityException e) {
Method readMethod = clazz.getDeclaredMethod(getIsMethodName(field.getName())); if (Modifier.isPublic(readMethod.getModifiers()) && !Modifier.isStatic(readMethod.getModifiers())) property.setReadMethod(readMethod);
Method readMethod = clazz.getDeclaredMethod(getIsMethodName(field.getName())); if (Modifier.isPublic(readMethod.getModifiers()) && !Modifier.isStatic(readMethod.getModifiers())) property.setReadMethod(readMethod);
Method readMethod = clazz.getDeclaredMethod(getIsMethodName(field.getName())); if (Modifier.isPublic(readMethod.getModifiers()) && !Modifier.isStatic(readMethod.getModifiers())) property.setReadMethod(readMethod);
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; } } }
try { if (existingPropDescriptor.getReadMethod() == null) { existingPropDescriptor.setReadMethod(superPropDescriptor.getReadMethod());
try { if (existingPropDescriptor.getReadMethod() == null) { existingPropDescriptor.setReadMethod(superPropDescriptor.getReadMethod());
try { if (existingPropDescriptor.getReadMethod() == null) { existingPropDescriptor.setReadMethod(superPropDescriptor.getReadMethod());
pda[i].setReadMethod(findClosestMatchingMethod(targetClass, pda[i].getReadMethod(), pda[i].getName(), pda[i].getPropertyType(), true));