Java Class Load fromString(Class clazz, String stringValue)

Here you can find the source of fromString(Class clazz, String stringValue)

Description

from String

License

Open Source License

Declaration

private static Object fromString(Class<?> clazz, String stringValue) 

Method Source Code

//package com.java2s;

public class Main {
    private static Object fromString(Class<?> clazz, String stringValue) {
        if (String.class == clazz) {
            return stringValue;
        } else if (Long.class == clazz) {
            return Long.valueOf(stringValue);
        }// www  .j a  v a 2s.  c  om

        // It seems only String and Long have chances of being used. Not adding other
        // classes to avoid having dead code, even though without them this looks incomplete.
        throw new IllegalArgumentException(
                "Instantiating " + clazz + " from string representation is not supported. Most likely an"
                        + " incompatible version of google-http-client was used.");
    }
}

Related

  1. classForName(String typeName)
  2. classForName(String typeName)
  3. classForNameNoThrow(String className)
  4. classForNameOrNull(final String className)
  5. classForNameOrPrimitive(String name, ClassLoader loader)
  6. fromString(Class clazz, String name)
  7. fromString(Class clz, String value, T defaultVal)
  8. fromString(Class enumClass, String s, T defaultValue)
  9. fromString(Class enumType, String text)