public ReflectiveProperty(Class<T> propertyHolder,Class<V> valueType,String name){
  super(valueType,name);
  char firstLetter=Character.toUpperCase(name.charAt(0));
  String theRest=name.substring(1);
  String capitalizedName=firstLetter + theRest;
  String getterName=PREFIX_GET + capitalizedName;
  try {
    mGetter=propertyHolder.getMethod(getterName,(Class<?>[])null);
  }
 catch (  NoSuchMethodException e) {
    try {
      mGetter=propertyHolder.getDeclaredMethod(getterName,(Class<?>[])null);
      mGetter.setAccessible(true);
    }
 catch (    NoSuchMethodException e2) {
      getterName=PREFIX_IS + capitalizedName;
      try {
        mGetter=propertyHolder.getMethod(getterName,(Class<?>[])null);
      }
 catch (      NoSuchMethodException e3) {
        try {
          mGetter=propertyHolder.getDeclaredMethod(getterName,(Class<?>[])null);
          mGetter.setAccessible(true);
        }
 catch (        NoSuchMethodException e4) {
          try {
            mField=propertyHolder.getField(name);
            Class fieldType=mField.getType();
            if (!typesMatch(valueType,fieldType)) {
              throw new NoSuchPropertyException("Underlying type (" + fieldType + ") "+ "does not match Property type ("+ valueType+ ")");
            }
            return;
          }
 catch (          NoSuchFieldException e5) {
            throw new NoSuchPropertyException("No accessor method or field found for" + " property with name " + name);
          }
        }
      }
    }
  }
  Class getterType=mGetter.getReturnType();
  if (!typesMatch(valueType,getterType)) {
    throw new NoSuchPropertyException("Underlying type (" + getterType + ") "+ "does not match Property type ("+ valueType+ ")");
  }
  String setterName=PREFIX_SET + capitalizedName;
  try {
    mSetter=propertyHolder.getDeclaredMethod(setterName,getterType);
    mSetter.setAccessible(true);
  }
 catch (  NoSuchMethodException ignored) {
  }
}

public ReflectiveProperty ( Class < T > propertyHolder , Class < V > valueType , String name ) { super ( valueType , name ) ; char firstLetter = Character . toUpperCase ( name . charAt ( 0 ) ) ; String theRest = name . substring ( 1 ) ; String capitalizedName = firstLetter + theRest ; String getterName = PREFIX_GET + capitalizedName ; try { mGetter = propertyHolder . getMethod ( getterName , ( Class < ? > [ ] ) null ) ; } catch ( NoSuchMethodException e ) { try { mGetter = propertyHolder . getDeclaredMethod ( getterName , ( Class < ? > [ ] ) null ) ; mGetter . setAccessible ( true ) ; } catch ( NoSuchMethodException e2 ) { getterName = PREFIX_IS + capitalizedName ; try { mGetter = propertyHolder . getMethod ( getterName , ( Class < ? > [ ] ) null ) ; } catch ( NoSuchMethodException e3 ) { try { mGetter = propertyHolder . getDeclaredMethod ( getterName , ( Class < ? > [ ] ) null ) ; mGetter . setAccessible ( true ) ; } catch ( NoSuchMethodException e4 ) { try { mField = propertyHolder . getField ( name ) ; Class fieldType = mField . getType ( ) ; if ( ! typesMatch ( valueType , fieldType ) ) { throw new NoSuchPropertyException ( "Underlying type (" + fieldType + ") " + "does not match Property type (" + valueType + ")" ) ; } return ; } catch ( NoSuchFieldException e5 ) { throw new NoSuchPropertyException ( "No accessor method or field found for" + " property with name " + name ) ; } } } } } Class getterType = mGetter . getReturnType ( ) ; if ( ! typesMatch ( valueType , getterType ) ) { throw new NoSuchPropertyException ( "Underlying type (" + getterType + ") " + "does not match Property type (" + valueType + ")" ) ; } String setterName = PREFIX_SET + capitalizedName ; try { mSetter = propertyHolder . getDeclaredMethod ( setterName , getterType ) ; mSetter . setAccessible ( true ) ; } catch ( NoSuchMethodException ignored ) { } }
for given property name ' name ' , look for getname / isname method or ' name ' field . also look for setname method ( optional - could be readonly ) . failing method getters and field results in throwing nosuchpropertyexception .
