@Override public boolean filter(Method method) throws Exception { if (resultTypeFilters != null) { b2.setMethod(method); b2.setArgumentValues(argumentValues); typeMapping = b2.build(new HashMap<String, SymbolType>(typeMapping)); SymbolType result = SymbolType.valueOf(method, typeMapping); List<Class<?>> classes = result.getBoundClasses(); resultTypeFilters.setElements(classes); return resultTypeFilters.filterOne() != null; } return false; }
@Override public Map<String, SymbolType> build(Map<String, SymbolType> obj) { if (obj == null) { obj = new HashMap<String, SymbolType>(); } TypeVariable<?>[] typeParams = clazz.getTypeParameters(); if (typeParams != null) { for (int i = 0; i < typeParams.length; i++) { if (parameterizedTypes != null) { if (i >= parameterizedTypes.size()) { SymbolType st = new SymbolType("java.lang.Object"); st.setTemplateVariable(typeParams[i].getName()); obj.put(typeParams[i].getName(), st); } else { if (parameterizedTypes.get(i).getName() == null && parameterizedTypes.get(i).hasBounds()) { obj.put(typeParams[i].getName(), parameterizedTypes.get(i)); } else { if (!"java.lang.Object".equals(parameterizedTypes.get(i).getName())) { obj.put(typeParams[i].getName(), parameterizedTypes.get(i)); } else { SymbolType st = new SymbolType("java.lang.Object"); st.setTemplateVariable(typeParams[i].getName()); obj.put(typeParams[i].getName(), st); } } } } else { Type[] bounds = typeParams[i].getBounds(); SymbolType resultType = null; if (bounds.length == 0) { resultType = new SymbolType("java.lang.Object"); } else { try { SymbolType auxSt = null; for (int j = 0; j < bounds.length; j++) { auxSt = SymbolType.valueOf(bounds[j], obj); if (resultType == null) { resultType = auxSt; } else { resultType = (SymbolType) resultType.merge(auxSt); } } } catch (InvalidTypeException e) { throw new RuntimeException("Error processing bounds of type ", e); } } if (resultType != null) { obj.put(typeParams[i].getName(), resultType); } } } } return obj; }