public static void addPropertyIntoObject(VolumeObjectProperties key,String value,Object instance) throws Exception {
  if (null != value) {
    Method method=PropertySetterUtil.getMethod(key.getMethodName(),instance);
    if (null == method) {
      return;
    }
    Object typeCastedValue=PropertySetterUtil.typeCast(value,method);
    if (null == typeCastedValue) {
      return;
    }
    Object[] args=new Object[]{typeCastedValue};
    if (null != method) {
      method.invoke(instance,args);
    }
  }
}

public static void addPropertyIntoObject ( VolumeObjectProperties key , String value , Object instance ) throws Exception { if ( null != value ) { Method method = PropertySetterUtil . getMethod ( key . getMethodName ( ) , instance ) ; if ( null == method ) { return ; } Object typeCastedValue = PropertySetterUtil . typeCast ( value , method ) ; if ( null == typeCastedValue ) { return ; } Object [ ] args = new Object [ ] { typeCastedValue } ; if ( null != method ) { method . invoke ( instance , args ) ; } } }
volumeobjectproperties , an enum , associating key with its methodname e . g . invoke volume . setallocatedcapacity ( allocatedcapacity ) . in the above example , allocatedcapacity is the key , and its methodname is setallocatedcapacity . this relation is maintained in volumeobjectproperties enum . the code looks clumsy , if we get each property from set , and invoke its associated method on volume instance . instead , the idea here is to use reflection to invoke the right method on volume instance , based on the key provided .
