Exemple #1
0
 private GenericInfo<T> applyArguments0(Type[] actualArguments) {
   Map<TypeVariable<?>, Type> genericArgumentMap = cloneGenericArgumentMap();
   Map<TypeVariable<?>, List<Listener>> listenerMapping = cloneListenerMapping();
   GenericInfo<T> genericInfo =
       new GenericInfo<T>(genericArgumentMap, listenerMapping, representingClass);
   genericInfo.doApplyArguments(actualArguments);
   return genericInfo;
 }
Exemple #2
0
 public GenericInfo<T> applyArguments(Type[] actualArguments) {
   if (this.userOperateFlag == true) {
     throw new IllegalStateException("has applied arguments.");
   }
   GenericInfo<T> genericInfo = applyArguments0(actualArguments);
   genericInfo.userOperateFlag = true;
   return genericInfo;
 }
Exemple #3
0
 @SuppressWarnings({"unchecked", "rawtypes"})
 public <C extends T> GenericInfo<C> build(Class<C> clazz) {
   if (userOperateFlag == true) {
     throw new IllegalStateException("has applied arguments.");
   }
   Type genericSuperclass = clazz.getGenericSuperclass();
   Class superClass;
   Type[] actualArguments;
   if (genericSuperclass == null) {
     if (addInterfaceGeneric) {
       GenericInfo genericInfo =
           new GenericInfo(
               new HashMap<TypeVariable<?>, Type>(),
               new HashMap<TypeVariable<?>, List<Listener>>(),
               clazz);
       genericInfo.addGenericInterfaces(clazz);
       return genericInfo;
     } else {
       return (GenericInfo) OBJECT_INFO; // 处理接口?
     }
   } else if (genericSuperclass instanceof Class) {
     superClass = (Class) genericSuperclass;
     actualArguments = null;
   } else {
     ParameterizedType parameterizedType = (ParameterizedType) genericSuperclass;
     superClass = (Class) parameterizedType.getRawType();
     actualArguments = parameterizedType.getActualTypeArguments();
   }
   GenericInfo superGenericInfo;
   if (superClass == representingClass) {
     superGenericInfo = this;
   } else {
     superGenericInfo = build(superClass);
   }
   GenericInfo child = superGenericInfo.applyArguments0(actualArguments);
   child.representingClass = clazz;
   if (addInterfaceGeneric) {
     child.addGenericInterfaces(clazz);
   }
   return child;
 }
Exemple #4
0
 public static <C> GenericInfo<C> get(Class<C> clazz) {
   return OBJECT_INFO.build(clazz);
 }