code: public <T> T to(Class<T> targetType) {
          if (targetType == String.class) {
              return (T) value;
          }
          try {
              final String methodName;
              final Class type;
              if (targetType.isPrimitive()) {
                  final String typeName = targetType.getSimpleName();
                  methodName = "parse" + typeName.substring(0, 1).toUpperCase() + typeName.substring(1);
                  type = PRIMITIVE_TO_OBJECT_TYPE_MAP.get(targetType);
              } else {
                  methodName = "valueOf";
                  type = targetType;
              }
              return (T) type.getMethod(methodName, String.class).invoke(null, value);
          } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
              throw new RuntimeException("Could not convert value '" + value + "' to type " + targetType.getName(), e);
          }
      }
docs: Converts the underlying string value to a primitive value.
  
  @param targetType
  the type into which the string value should be converted.
  
  @param <T>
  the type of the target type
  
  @return the converted value.