Code example for TypeToken

Methods: getRawType

  public void visit(Object instance, TypeToken<?> inspectType, TypeToken<?> declareType, Field field) throws Exception {
    if (field.isAnnotationPresent(Property.class)) {
      String key = declareType.getRawType().getName() + '.' + field.getName();
      String value = properties.get(key);
      if (value == null) {
      setValue(instance, field, value);
   * Sets the value of the field in the given instance by converting the value from String to the field type. 
   * Currently only allows primitive types, boxed types, String and Enum. 
  private void setValue(Object instance, Field field, String value) throws IllegalAccessException {