private Result equalsParametrizedTypes(List<Type> commandParametrizedTypes, List<Type> fallbackParametrizedTypes) { if (commandParametrizedTypes.size() != fallbackParametrizedTypes.size()) { return Result.failure(Collections.singletonList( new Error("Different size of types variables.\n" + "Command type literals size = " + commandParametrizedTypes.size() + ": " + commandParametrizedTypes + "\n" + "Fallback type literals size = " + fallbackParametrizedTypes.size() + ": " + fallbackParametrizedTypes + "\n" ))); } for (int i = 0; i < commandParametrizedTypes.size(); i++) { Type commandParametrizedType = commandParametrizedTypes.get(i); Type fallbackParametrizedType = fallbackParametrizedTypes.get(i); Result result = equals(commandParametrizedType, fallbackParametrizedType); if (!result.success) return result; } return SUCCESS; }
final TypeVariable tv2 = (TypeVariable) fallbackType; if (tv1.getGenericDeclaration() instanceof Method && tv2.getGenericDeclaration() instanceof Method) { Result result = equals(tv1.getBounds(), tv2.getBounds()); return result.append(new Supplier<List<Error>>() { @Override final WildcardType wt1 = (WildcardType) commandType; final WildcardType wt2 = (WildcardType) fallbackType; Result result = equals(wt1.getLowerBounds(), wt2.getLowerBounds()); result = result.append(new Supplier<List<Error>>() { @Override result = equals(wt1.getUpperBounds(), wt2.getUpperBounds()); return result.append(new Supplier<List<Error>>() { @Override
private static Result equals(Type[] t1, Type[] t2) { if (t1 == null && t2 == null) return SUCCESS; if (t1 == null) return Result.failure(); if (t2 == null) return Result.failure(); if (t1.length != t2.length) return Result.failure(new Error(String.format("Different size of type literals. Command size = %d, fallback size = %d", t1.length, t2.length))); Result result = SUCCESS; for (int i = 0; i < t1.length; i++) { result = result.combine(equals(t1[i], t2[i])); if (result.isFailure()) return result; } return result; }
private Result equalsParametrizedTypes(List<Type> commandParametrizedTypes, List<Type> fallbackParametrizedTypes) { if (commandParametrizedTypes.size() != fallbackParametrizedTypes.size()) { return Result.failure(Collections.singletonList( new Error("Different size of types variables.\n" + "Command type literals size = " + commandParametrizedTypes.size() + ": " + commandParametrizedTypes + "\n" + "Fallback type literals size = " + fallbackParametrizedTypes.size() + ": " + fallbackParametrizedTypes + "\n" ))); } for (int i = 0; i < commandParametrizedTypes.size(); i++) { Type commandParametrizedType = commandParametrizedTypes.get(i); Type fallbackParametrizedType = fallbackParametrizedTypes.get(i); Result result = equals(commandParametrizedType, fallbackParametrizedType); if (!result.success) return result; } return SUCCESS; }
final TypeVariable tv2 = (TypeVariable) fallbackType; if (tv1.getGenericDeclaration() instanceof Method && tv2.getGenericDeclaration() instanceof Method) { Result result = equals(tv1.getBounds(), tv2.getBounds()); return result.append(new Supplier<List<Error>>() { @Override final WildcardType wt1 = (WildcardType) commandType; final WildcardType wt2 = (WildcardType) fallbackType; Result result = equals(wt1.getLowerBounds(), wt2.getLowerBounds()); result = result.append(new Supplier<List<Error>>() { @Override result = equals(wt1.getUpperBounds(), wt2.getUpperBounds()); return result.append(new Supplier<List<Error>>() { @Override
private static Result equals(Type[] t1, Type[] t2) { if (t1 == null && t2 == null) return SUCCESS; if (t1 == null) return Result.failure(); if (t2 == null) return Result.failure(); if (t1.length != t2.length) return Result.failure(new Error(String.format("Different size of type literals. Command size = %d, fallback size = %d", t1.length, t2.length))); Result result = SUCCESS; for (int i = 0; i < t1.length; i++) { result = result.combine(equals(t1[i], t2[i])); if (result.isFailure()) return result; } return result; }