/** * 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()); }
public static boolean isGenericReturnType(Method method) { return isParametrizedType(method.getGenericReturnType()) || isTypeVariable(method.getGenericReturnType()); }
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;
/** * 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()); }
public static boolean isGenericReturnType(Method method) { return isParametrizedType(method.getGenericReturnType()) || isTypeVariable(method.getGenericReturnType()); }
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;