Code example for TypeToken

Methods: getRawType

0
     
    /** returns the Class of anything which isn't a class; if input is class it is pass-through */ 
    public static Class<?> type(Object x) {
        if (x==null) return null; 
        if (x instanceof Class) return (Class<?>)x;
        if (x instanceof TypeToken) return ((TypeToken<?>)x).getRawType();
        return x.getClass(); 
    } 
 
    /** like type, but removes any array modifiers */ 
    public static Class<?> componentType(Object x) {
        Class<?> c = type(x);
        if (c==null) return null;
        while (c.isArray()) {
            c = c.getComponentType();
        } 
        return c;
    } 
 
    /**  returns a simplified name of the class, just the simple name if it seems useful, else the full name */ 
Contextual code suggestions in your IDE  Get Codota for Java