/** * Adds all messages from the given ValidationResult * to the list of messages that this validation result holds. * * @param validationResult the validation result to add messages from * * @throws NullPointerException if the validation result is {@code null} * @throws UnsupportedOperationException if the result is unmodifiable * * @see #addAll(List) */ public void addAllFrom(ValidationResult validationResult) { checkModifiable(); checkNotNull(validationResult, "The validation result to add must not be null."); addAll(validationResult.messageList); }
/** * Adds all messages from the given list to this validation result. * * @param messages the messages to be added * * @throws NullPointerException if the messages list is {@code null} * @throws UnsupportedOperationException if the result is unmodifiable * @throws IllegalArgumentException if the messages list contains * a message with severity {@code OK} * * @see #addAllFrom(ValidationResult) */ public void addAll(List<ValidationMessage> messages) { checkModifiable(); checkNotNull(messages, "The messages list must not be null."); for (ValidationMessage message : messages) { checkArgument(message.severity() != Severity.OK, "You must not add a validation message with severity OK."); } messageList.addAll(messages); }
/** * Adds a new ValidationMessage to the list of messages. * * @param validationMessage the message to add * * @return this validation result * * @throws NullPointerException if the message is {@code null} * @throws UnsupportedOperationException if the result is unmodifiable * @throws IllegalArgumentException if the severity is {@code OK} * * @see #addError(String) * @see #addWarning(String) */ public ValidationResult add(ValidationMessage validationMessage) { checkModifiable(); checkNotNull(validationMessage, "The validation message must not be null."); checkArgument(validationMessage.severity() != Severity.OK, "You must not add a validation message with severity OK."); messageList.add(validationMessage); return this; }
/** * Creates and adds a warning message to the list of validation messages * using the given validation message key, (format) text and optional * format arguments. * * @param key the key used to associate messages and components * @param text the format text to add * @param args optional text format arguments * * * @throws NullPointerException if the message text is {@code null} * @throws IllegalArgumentException if the message text is empty or whitespace * @throws UnsupportedOperationException if the result is unmodifiable * * @see #add(ValidationMessage) * @see #addError(String) * * @since 2.6 */ private ValidationResult addWarning(Object key, String text, Object... args) { checkModifiable(); add(new SimpleValidationMessage(Strings.get(text, args), Severity.WARNING, key)); return this; }
/** * Creates and adds an error message to the list of validation messages * using the given validation message key, (format) text and optional * format arguments. * * @param key the key used to associate messages and components * @param text the format text to add * @param args optional text format arguments * * * @throws NullPointerException if the message text is {@code null} * @throws IllegalArgumentException if the message text is empty or whitespace * @throws UnsupportedOperationException if the result is unmodifiable * * @see #add(ValidationMessage) * @see #addWarning(String) * * @since 2.6 */ private ValidationResult addError(Object key, String text, Object... args) { checkModifiable(); add(new SimpleValidationMessage(Strings.get(text, args), Severity.ERROR, key)); return this; }
/** * Creates and adds an info message to the list of validation messages * using the given validation message key, (format) text and optional * format arguments. * * @param key the key used to associate messages and components * @param text the format text to add * @param args optional text format arguments * * * @throws NullPointerException if the message text is {@code null} * @throws IllegalArgumentException if the message text is empty or whitespace * @throws UnsupportedOperationException if the result is unmodifiable * * @see #add(ValidationMessage) * @see #addError(String) * * @since 2.6 */ private ValidationResult addInfo(Object key, String text, Object... args) { checkModifiable(); add(new SimpleValidationMessage(Strings.get(text, args), Severity.INFO, key)); return this; }