private void addCodes(Collection<String> codeList, String errorCode, @Nullable String objectName, Iterable<String> fields) { for (String field : fields) { addCode(codeList, errorCode, objectName, field); } }
/** * Build the code list for the given code and field: an * object/field-specific code, a field-specific code, a plain error code. * <p>Arrays, Lists and Maps are resolved both for specific elements and * the whole collection. * <p>See the {@link DefaultMessageCodesResolver class level javadoc} for * details on the generated codes. * @return the list of codes */ @Override public String[] resolveMessageCodes(String errorCode, String objectName, String field, @Nullable Class<?> fieldType) { Set<String> codeList = new LinkedHashSet<>(); List<String> fieldList = new ArrayList<>(); buildFieldList(field, fieldList); addCodes(codeList, errorCode, objectName, fieldList); int dotIndex = field.lastIndexOf('.'); if (dotIndex != -1) { buildFieldList(field.substring(dotIndex + 1), fieldList); } addCodes(codeList, errorCode, null, fieldList); if (fieldType != null) { addCode(codeList, errorCode, null, fieldType.getName()); } addCode(codeList, errorCode, null, null); return StringUtils.toStringArray(codeList); }
/** * Build the code list for the given code and field: an * object/field-specific code, a field-specific code, a plain error code. * <p>Arrays, Lists and Maps are resolved both for specific elements and * the whole collection. * <p>See the {@link DefaultMessageCodesResolver class level javadoc} for * details on the generated codes. * @return the list of codes */ @Override public String[] resolveMessageCodes(String errorCode, String objectName, String field, @Nullable Class<?> fieldType) { Set<String> codeList = new LinkedHashSet<>(); List<String> fieldList = new ArrayList<>(); buildFieldList(field, fieldList); addCodes(codeList, errorCode, objectName, fieldList); int dotIndex = field.lastIndexOf('.'); if (dotIndex != -1) { buildFieldList(field.substring(dotIndex + 1), fieldList); } addCodes(codeList, errorCode, null, fieldList); if (fieldType != null) { addCode(codeList, errorCode, null, fieldType.getName()); } addCode(codeList, errorCode, null, null); return StringUtils.toStringArray(codeList); }
private void addCodes(Collection<String> codeList, String errorCode, @Nullable String objectName, Iterable<String> fields) { for (String field : fields) { addCode(codeList, errorCode, objectName, field); } }
/** * Build the code list for the given code and field: an * object/field-specific code, a field-specific code, a plain error code. * <p>Arrays, Lists and Maps are resolved both for specific elements and * the whole collection. * <p>See the {@link DefaultMessageCodesResolver class level javadoc} for * details on the generated codes. * @return the list of codes */ @Override public String[] resolveMessageCodes(String errorCode, String objectName, String field, @Nullable Class<?> fieldType) { Set<String> codeList = new LinkedHashSet<>(); List<String> fieldList = new ArrayList<>(); buildFieldList(field, fieldList); addCodes(codeList, errorCode, objectName, fieldList); int dotIndex = field.lastIndexOf('.'); if (dotIndex != -1) { buildFieldList(field.substring(dotIndex + 1), fieldList); } addCodes(codeList, errorCode, null, fieldList); if (fieldType != null) { addCode(codeList, errorCode, null, fieldType.getName()); } addCode(codeList, errorCode, null, null); return StringUtils.toStringArray(codeList); }
private void addCodes(Collection<String> codeList, String errorCode, @Nullable String objectName, Iterable<String> fields) { for (String field : fields) { addCode(codeList, errorCode, objectName, field); } }