/** * Constructs a new generic type, supplying the generic type * information and derving the class. * * @param genericType the generic type. * @throws IllegalArgumentException if genericType * is null or is neither an instance of Class or ParameterizedType whose raw * type is not an instance of Class. */ public GenericType(Type genericType) { if (genericType == null) { throw new IllegalArgumentException("Type must not be null"); } this.t = genericType; this.c = getClass(this.t); }
/** * Constructs a new generic type, supplying the generic type * information and derving the class. * * @param genericType the generic type. * @throws IllegalArgumentException if genericType * is null or is neither an instance of Class or ParameterizedType whose raw * type is not an instance of Class. */ public GenericType(Type genericType) { if (genericType == null) { throw new IllegalArgumentException("Type must not be null"); } this.t = genericType; this.c = getClass(this.t); }
/** * Constructs a new generic type, deriving the generic type and class from * type parameter. Note that this constructor is protected, users should create * a (usually anonymous) subclass as shown above. * */ protected GenericType() { Type superclass = getClass().getGenericSuperclass(); if (!(superclass instanceof ParameterizedType)) { throw new RuntimeException("Missing type parameter."); } ParameterizedType parameterized = (ParameterizedType) superclass; this.t = parameterized.getActualTypeArguments()[0]; this.c = getClass(this.t); }
/** * Constructs a new generic type, deriving the generic type and class from * type parameter. Note that this constructor is protected, users should create * a (usually anonymous) subclass as shown above. * */ protected GenericType() { Type superclass = getClass().getGenericSuperclass(); if (!(superclass instanceof ParameterizedType)) { throw new RuntimeException("Missing type parameter."); } ParameterizedType parameterized = (ParameterizedType) superclass; this.t = parameterized.getActualTypeArguments()[0]; this.c = getClass(this.t); }