private static Error boundsError(Type t1, Type[] b1, String boundType, Type t2, Type[] b2) { return new Error(t1, String.format("Different %s bounds. Command bounds: '%s'; Fallback bounds: '%s'", boundType, StringUtils.join(b1, ", "), StringUtils.join(b2, ", ")), t2); }
@Override public List<Error> get() { return Collections.singletonList(new Error( commandType, String.format("Different types. Command type: '%s'; fallback type: '%s'", commandType, fallbackType), fallbackType)); } });
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; }
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; }
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 static Error boundsError(Type t1, Type[] b1, String boundType, Type t2, Type[] b2) { return new Error(t1, String.format("Different %s bounds. Command bounds: '%s'; Fallback bounds: '%s'", boundType, StringUtils.join(b1, ", "), StringUtils.join(b2, ", ")), t2); }
@Override public List<Error> get() { return Collections.singletonList(new Error( commandType, String.format("Different types. Command type: '%s'; fallback type: '%s'", commandType, fallbackType), fallbackType)); } });
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; }