private void validateReturnType(Method commandMethod, Method fallbackMethod) { if (isGenericReturnType(commandMethod)) { List<Type> commandParametrizedTypes = flattenTypeVariables(commandMethod.getGenericReturnType()); List<Type> fallbackParametrizedTypes = flattenTypeVariables(fallbackMethod.getGenericReturnType()); Result result = equalsParametrizedTypes(commandParametrizedTypes, fallbackParametrizedTypes); if (!result.success) { List<String> msg = new ArrayList<String>(); for (Error error : result.errors) { Optional<Type> parentKindOpt = getParentKind(error.commandType, commandParametrizedTypes); String extraHint = ""; if (parentKindOpt.isPresent()) { Type parentKind = parentKindOpt.get(); if (isParametrizedType(parentKind)) { extraHint = "--> " + ((ParameterizedType) parentKind).getRawType().toString() + "<Ooops!>\n"; } } msg.add(String.format(error.reason + "\n" + extraHint + "Command type literal pos: %s; Fallback type literal pos: %s", positionAsString(error.commandType, commandParametrizedTypes), positionAsString(error.fallbackType, fallbackParametrizedTypes))); } throw new FallbackDefinitionException(createErrorMsg(commandMethod, method, StringUtils.join(msg, "\n"))); } } validatePlainReturnType(commandMethod, fallbackMethod); }
private void validateReturnType(Method commandMethod, Method fallbackMethod) { if (isGenericReturnType(commandMethod)) { List<Type> commandParametrizedTypes = flattenTypeVariables(commandMethod.getGenericReturnType()); List<Type> fallbackParametrizedTypes = flattenTypeVariables(fallbackMethod.getGenericReturnType()); Result result = equalsParametrizedTypes(commandParametrizedTypes, fallbackParametrizedTypes); if (!result.success) { List<String> msg = new ArrayList<String>(); for (Error error : result.errors) { Optional<Type> parentKindOpt = getParentKind(error.commandType, commandParametrizedTypes); String extraHint = ""; if (parentKindOpt.isPresent()) { Type parentKind = parentKindOpt.get(); if (isParametrizedType(parentKind)) { extraHint = "--> " + ((ParameterizedType) parentKind).getRawType().toString() + "<Ooops!>\n"; } } msg.add(String.format(error.reason + "\n" + extraHint + "Command type literal pos: %s; Fallback type literal pos: %s", positionAsString(error.commandType, commandParametrizedTypes), positionAsString(error.fallbackType, fallbackParametrizedTypes))); } throw new FallbackDefinitionException(createErrorMsg(commandMethod, method, StringUtils.join(msg, "\n"))); } } validatePlainReturnType(commandMethod, fallbackMethod); }