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 static Result equals(Type commandType, Type fallbackType) { if (isParametrizedType(commandType) && isParametrizedType(fallbackType)) { final ParameterizedType pt1 = (ParameterizedType) commandType; final ParameterizedType pt2 = (ParameterizedType) fallbackType; } else if (isTypeVariable(commandType) && isTypeVariable(fallbackType)) { final TypeVariable tv1 = (TypeVariable) commandType; final TypeVariable tv2 = (TypeVariable) fallbackType; } else if (isWildcardType(commandType) && isWildcardType(fallbackType)) { final WildcardType wt1 = (WildcardType) commandType; final WildcardType wt2 = (WildcardType) fallbackType;
public static boolean isGenericReturnType(Method method) { return isParametrizedType(method.getGenericReturnType()) || isTypeVariable(method.getGenericReturnType()); }
/** * Check whether return type of the given method is parametrized or not. * * @param method the method * @return true - if return type is {@link ParameterizedType}, otherwise - false */ public static boolean isReturnTypeParametrized(Method method) { return isParametrizedType(method.getGenericReturnType()); }
if (isReturnTypeParametrized(commandMethod)) { commandParametrizedType = getFirstParametrizedType(commandMethod); if (isReturnTypeParametrized(commandMethod)) { commandParametrizedType = getFirstParametrizedType(commandMethod);
public static boolean isGenericReturnType(Method method) { return isParametrizedType(method.getGenericReturnType()) || isTypeVariable(method.getGenericReturnType()); }
/** * Check whether return type of the given method is parametrized or not. * * @param method the method * @return true - if return type is {@link ParameterizedType}, otherwise - false */ public static boolean isReturnTypeParametrized(Method method) { return isParametrizedType(method.getGenericReturnType()); }
if (ExecutionType.OBSERVABLE != getExecutionType()) { Type commandParametrizedType = commandMethod.getGenericReturnType(); if (isReturnTypeParametrized(commandMethod)) { commandParametrizedType = getFirstParametrizedType(commandMethod); if (isReturnTypeParametrized(commandMethod)) { commandParametrizedType = getFirstParametrizedType(commandMethod);
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 static Result equals(Type commandType, Type fallbackType) { if (isParametrizedType(commandType) && isParametrizedType(fallbackType)) { final ParameterizedType pt1 = (ParameterizedType) commandType; final ParameterizedType pt2 = (ParameterizedType) fallbackType; } else if (isTypeVariable(commandType) && isTypeVariable(fallbackType)) { final TypeVariable tv1 = (TypeVariable) commandType; final TypeVariable tv2 = (TypeVariable) fallbackType; } else if (isWildcardType(commandType) && isWildcardType(fallbackType)) { final WildcardType wt1 = (WildcardType) commandType; final WildcardType wt2 = (WildcardType) fallbackType;