return reflectClass.getAccessor().invokeMethod(instance, accessorIndex, args);
public Object getValue(Object instance,boolean useGetter) { try { if(useGetter && null != getter){ if(getterAccessorIndex != -1){ return accessor.invokeMethod(instance, getterAccessorIndex, Arrays2.EMPTY_OBJECT_ARRAY); }else{ return getter.invoke(instance, Arrays2.EMPTY_OBJECT_ARRAY); } }else{ if(fieldAccessorIndex != -1){ return accessor.getFieldValue(instance, fieldAccessorIndex); }else { return field.get(instance); } } } catch (Throwable e) { if(e instanceof InvocationTargetException){ e = e.getCause(); } if(e instanceof RuntimeException){ throw (RuntimeException)e; } throw new ReflectException(Strings.format("Error getting value of field '{0}'",getName()),e); } }
public void setValue(Object instance, Object value, boolean useSetter) { try { if(field.isSynthetic() || isFinal()){ field.set(instance, safeValue(value)); }else{ if(useSetter && null != setter){ if(setterAccessorIndex != -1){ accessor.invokeMethod(instance, setterAccessorIndex, safeValue(value)); }else{ setter.invoke(instance, safeValue(value)); } }else{ if(fieldAccessorIndex != -1){ accessor.setFieldValue(instance, fieldAccessorIndex, safeValue(value)); }else{ field.set(instance, safeValue(value)); } } } } catch (Exception e) { throw new ReflectException(Strings.format("Error setting value '{0}' to field '{1}'",value,getName()),e); } }