code: public static Object convertExample(String value, String type) {
          if (value == null) {
              return null;
          }
  
          try {
              switch (type) {
                  case "integer":
                      return Integer.valueOf(value);
                  case "number":
                      return Float.valueOf(value);
                  case "boolean":
                      return Boolean.valueOf(value);
                  case "string":
                      return value;
                  default:
                      return value;
              }
          } catch (NumberFormatException e) {
              throw new RuntimeException(String.format("Value '%s' cannot be converted to '%s'", value, type), e);
          }
      }
docs: Convert a string {@code value} to specified {@code type}.
  
  @param value value to convert
  @param type  target conversion type
  @return converted value as object