code: public static <T> T getValue(Object target, Field field, Class<T> type) {
      try {
        boolean currentAccessible = field.isAccessible();
        field.setAccessible(true);
        Object value = field.get(target);
        field.setAccessible(currentAccessible);
        return type.cast(value);
      }
      catch (NullPointerException e) {
        throw e;
      }
      catch (Exception e) {
        throw new FieldAccessException(String.format("Failed to get value of field (%1$s) from %2$s type (%3$s)!",
          field.getName(), BooleanUtils.toString(target == null, "class", "object of"), getClassName(target)), e);
      }
    }
docs: Gets the value of the field on the given object cast to the desired class type.  If the "target" object is null,
  then this method assumes the field is a static (class) member field; otherwise the field is considered
  an instance (object) member field.  This method is not null-safe!
  
  @param <T> the desired return type in which the field's value will be cast; should be compatible with
  the field's declared type.
  @param target the Object on which the field is defined.
  @param field the specified Field from which to get the value.
  @param type the desired return type of the field's value; should be compatible with the field's declared type.
  @return the value of the given field on the given object cast to the desired type.
  @throws FieldAccessException if the value for the specified field could not be retrieved.
  @throws NullPointerException if the field or type parameter arguments are null.