Esempio n. 1
0
 private void parseArgument(TypeVariable<?> declaredParameter, Type actualArgument) {
   if (actualArgument instanceof Class) {
     changeGeneric(declaredParameter, actualArgument);
   } else if (actualArgument instanceof ParameterizedType
       || actualArgument instanceof GenericArrayType) {
     GenericAnalyzeResult analyzeResult = new GenericAnalyzeResult(actualArgument);
     addGeneric(declaredParameter, analyzeResult.getStatefulGenericType());
     List<VarPath> varPaths = analyzeResult.getVarPaths();
     if (varPaths.size() == 0) {
       changeGeneric(declaredParameter, actualArgument);
     } else {
       Map<TypeVariable<?>, List<int[]>> varPathMap = new HashMap<TypeVariable<?>, List<int[]>>();
       for (VarPath varPath : varPaths) {
         List<int[]> pathList = varPathMap.get(varPath.var);
         if (pathList == null) {
           pathList = new LinkedList<int[]>();
           varPathMap.put(varPath.var, pathList);
         }
         pathList.add(varPath.path);
       }
       for (Entry<TypeVariable<?>, List<int[]>> entry : varPathMap.entrySet()) {
         addListener(entry.getKey(), new GenericTypeReplace(declaredParameter, entry.getValue()));
       }
     }
   } else if (actualArgument instanceof TypeVariable) {
     addGeneric(declaredParameter, actualArgument);
     addListener((TypeVariable<?>) actualArgument, new TypeReplace(declaredParameter));
   } else if (actualArgument instanceof WildcardType) {
     throw new IllegalArgumentException(
         "cannot handle WildcardType, try resolveActualArgument or resolveComponentGenericType in parent first:"
             + actualArgument);
   } else {
     throw new IllegalArgumentException("unknown type:" + actualArgument);
   }
 }