private static Method findGetter(Object instance, Class valueType, String property) throws NoSuchMethodException { NoSuchMethodException nsme; try { return findAccessibleClass(instance.getClass()).getMethod( firstLetterToUpperCase(property, "get") ); } catch (NoSuchMethodException e) { if (valueType != boolean.class) { throw e; } else { nsme = e; } } // Is of type boolean and "get" getter does not exist try { return findAccessibleClass(instance.getClass()).getMethod( firstLetterToUpperCase(property, "is") ); } catch (NoSuchMethodException e) { throw e; } }
/** Create a support based on the property name. * The getter and setter methods are constructed by capitalizing the first * letter in the name of propety and prefixing it with <code>get</code> and * <code>set</code>, respectively. * * @param instance object to work on * @param valueType type of the property * @param property name of property * @exception NoSuchMethodException if the getter or setter methods cannot be found */ public Reflection(Object instance, Class<T> valueType, String property) throws NoSuchMethodException { this( instance, valueType, findGetter(instance, valueType, property), findAccessibleClass(instance.getClass()).getMethod( firstLetterToUpperCase(property, "set"), valueType ) ); }
private static Method findGetter( Object instance, Class valueType, String property ) throws NoSuchMethodException { NoSuchMethodException nsme; try { return findAccessibleClass (instance.getClass ()).getMethod ( firstLetterToUpperCase (property, "get"), new Class[0] ); } catch ( NoSuchMethodException e ) { if ( valueType != boolean.class ) { throw e; } else { nsme = e; } } // Is of type boolean and "get" getter does not exist try { return findAccessibleClass (instance.getClass ()).getMethod ( firstLetterToUpperCase (property, "is"), new Class[0] ); } catch ( NoSuchMethodException e ) { throw e; } }
private static Method findGetter( Object instance, Class valueType, String property ) throws NoSuchMethodException { NoSuchMethodException nsme; try { return findAccessibleClass (instance.getClass ()).getMethod ( firstLetterToUpperCase (property, "get"), new Class[0] ); } catch ( NoSuchMethodException e ) { if ( valueType != boolean.class ) { throw e; } else { nsme = e; } } // Is of type boolean and "get" getter does not exist try { return findAccessibleClass (instance.getClass ()).getMethod ( firstLetterToUpperCase (property, "is"), new Class[0] ); } catch ( NoSuchMethodException e ) { throw e; } }
/** Create a support based on the property name. * The getter and setter methods are constructed by capitalizing the first * letter in the name of propety and prefixing it with <code>get</code> and * <code>set</code>, respectively. * * @param instance object to work on * @param valueType type of the property * @param property name of property * @exception NoSuchMethodException if the getter or setter methods cannot be found */ public Reflection (Object instance, Class valueType, String property) throws NoSuchMethodException { this ( instance, valueType, findGetter( instance, valueType, property ), findAccessibleClass (instance.getClass ()).getMethod ( firstLetterToUpperCase (property, "set"), new Class[] { valueType } ) ); }
/** Create a support based on the property name. * The getter and setter methods are constructed by capitalizing the first * letter in the name of propety and prefixing it with <code>get</code> and * <code>set</code>, respectively. * * @param instance object to work on * @param valueType type of the property * @param property name of property * @exception NoSuchMethodException if the getter or setter methods cannot be found */ public Reflection (Object instance, Class valueType, String property) throws NoSuchMethodException { this ( instance, valueType, findGetter( instance, valueType, property ), findAccessibleClass (instance.getClass ()).getMethod ( firstLetterToUpperCase (property, "set"), new Class[] { valueType } ) ); }