/** * Returns the highest severity of this result's messages, * {@code Severity.OK} if there are no messages. * A single validation message can have only the severity * error or warning. Hence, this method returns the error severity * if there's at least one error message; and it returns * the warning severity, otherwise - assuming that there are * no other severities.<p> * * @param messages the List of ValidationMessages to check * @return the highest severity of this result's messages, * {@code Severity.OK} if there are no messages */ private static Severity getSeverity(List<ValidationMessage> messages) { Severity severity = Severity.OK; for (ValidationMessage message : messages) { severity = Severity.max(severity, message.severity()); if (severity.ordinal() == 0) { // we found the maximum severity. break; } } return severity; }
@Override public int compare(ValidationMessage o1, ValidationMessage o2) { return o1.severity().compareTo(o2.severity()); } }
/** * Returns the hash code value for this validation message. * This implementation computes and returns the hash based * on the hash code values of this messages' severity, key, * and text. * * @return the hash code value for this validation message. * * @see Object#hashCode() */ @Override public int hashCode() { String formattedText = formattedText(); int result = 17; result = 37 * result + severity().hashCode(); result = 37 * result + (key() == null ? 0 : key().hashCode()); result = 37 * result + (formattedText == null ? 0 : formattedText.hashCode()); return result; }
return severity().equals(other.severity()) && Objects.equals(key(), other.key()) && Objects.equals(formattedText(), other.formattedText());
/** * Returns the higher of the given severities by comparing their ordinals. * Since the higher severities have a lower ordinal, this method returns * the severity with the lower ordinal. * * @param severity1 the first severity to check * @param severity2 the second severity to check * @return the higher of the given severities */ public static Severity max(Severity severity1, Severity severity2) { return severity1.ordinal() < severity2.ordinal() ? severity1 : severity2; }
/** * Returns the hash code value for this validation message. * This implementation computes and returns the hash based * on the hash code values of this messages' severity, key, * and text. * * @return the hash code value for this validation message. * * @see Object#hashCode() */ @Override public int hashCode() { String formattedText = formattedText(); int result = 17; result = 37 * result + severity().hashCode(); result = 37 * result + (key() == null ? 0 : key().hashCode()); result = 37 * result + (formattedText == null ? 0 : formattedText.hashCode()); return result; }
return severity().equals(other.severity()) && ValidationUtils.equals(key(), other.key()) && ValidationUtils.equals(formattedText(), other.formattedText());
/** * Returns the higher of the given severities by comparing their ordinals. * Since the higher severities have a lower ordinal, this method returns * the severity with the lower ordinal. * * @param severity1 the first severity to check * @param severity2 the second severity to check * @return the higher of the given severities */ public static Severity max(Severity severity1, Severity severity2) { return severity1.ordinal() < severity2.ordinal() ? severity1 : severity2; }
/** * Returns the hash code value for this validation message. * This implementation computes and returns the hash based * on the hash code values of this messages' severity, text, * target, role, and property.<p> * * If this class could be extended, we should check if the formatted text * is {@code null}. * * @return the hash code value for this validation message. * * @see Object#hashCode() */ @Override public int hashCode() { int result = 17; result = 37 * result + severity().hashCode(); result = 37 * result + (text() == null ? 0 : text().hashCode()); result = 37 * result + (target() == null ? 0 : target().hashCode()); result = 37 * result + (role() == null ? 0 : role().hashCode()); result = 37 * result + (property() == null ? 0 : property().hashCode()); return result; }
return severity().equals(other.severity()) && Objects.equals(text(), other.text()) && Objects.equals(target(), other.target())
/** * Returns the hash code value for this validation message. * This implementation computes and returns the hash based * on the hash code values of this messages' severity, text, * target, role, and property.<p> * * If this class could be extended, we should check if the formatted text * is {@code null}. * * @return the hash code value for this validation message. * * @see Object#hashCode() */ @Override public int hashCode() { int result = 17; result = 37 * result + severity().hashCode(); result = 37 * result + (text() == null ? 0 : text().hashCode()); result = 37 * result + (target() == null ? 0 : target().hashCode()); result = 37 * result + (role() == null ? 0 : role().hashCode()); result = 37 * result + (property() == null ? 0 : property().hashCode()); return result; }
return false; PropertyValidationMessage other = (PropertyValidationMessage) o; return severity().equals(other.severity()) && ValidationUtils.equals(text(), other.text()) && ValidationUtils.equals(target(), other.target())