- java.lang.Object
-
- de.mlo.dev.validation.ValidationResult
-
- All Implemented Interfaces:
Iterable<ValidationInfo>
public class ValidationResult extends Object implements Iterable<ValidationInfo>
- Author:
- mlo
-
-
Field Summary
Fields Modifier and Type Field Description static StringLINE_SEPARATORThe system line separator
-
Constructor Summary
Constructors Constructor Description ValidationResult()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ValidationResultadd(ValidationInfo validationInfo)Adds a newValidationInfoat the end of the list.ValidationResultadd(ValidationInfo first, ValidationInfo... more)Adds one or moreValidationInfos at the end of the listValidationResultadd(ValidationResult validationResult)Merges the givenValidationResultinto this result.ValidationResultadd(Collection<ValidationInfo> validationInfos)Adds a bunch ofValidationInfos at the end of the listList<ValidationInfo>getInfos()StringgetMessage()StringgetMessage(String delimiter)List<String>getMessages()static ValidationResultinvalid(String message)Convenient function: Creates aValidationResultwith onValidationInfowhich is invalid and contains the given message.
Caution: If a process combinesresultsthe end result will be invalid.booleanisInvalid()booleanisValid()Iterator<ValidationInfo>iterator()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Field Detail
-
LINE_SEPARATOR
public static final String LINE_SEPARATOR
The system line separator
-
-
Method Detail
-
invalid
public static ValidationResult invalid(String message)
Convenient function: Creates aValidationResultwith onValidationInfowhich is invalid and contains the given message.
Caution: If a process combinesresultsthe end result will be invalid.- Parameters:
message- A description why the result is invalid- Returns:
- A new instance of a
ValidationResult
-
add
public ValidationResult add(ValidationResult validationResult)
Merges the givenValidationResultinto this result. The given result object is not touched. TheValidationInfos from the given container are transferred to this container.- Parameters:
validationResult- An already existent result container- Returns:
- An instance of this
ValidationResult
-
add
public ValidationResult add(ValidationInfo first, ValidationInfo... more)
Adds one or moreValidationInfos at the end of the list- Parameters:
first- Single information about the validation processmore- A list of information about the validation process- Returns:
- An instance of this
ValidationResult
-
add
public ValidationResult add(Collection<ValidationInfo> validationInfos)
Adds a bunch ofValidationInfos at the end of the list- Parameters:
validationInfos- A list of information about the validation process- Returns:
- An instance of this
ValidationResult
-
add
public ValidationResult add(ValidationInfo validationInfo)
Adds a newValidationInfoat the end of the list.- Parameters:
validationInfo- Single information about the validation process- Returns:
- An instance of this
ValidationResult
-
isValid
public boolean isValid()
- Returns:
trueif allValidationInfos are valid
-
isInvalid
public boolean isInvalid()
- Returns:
trueif one of theValidationInfos is invalid
-
getInfos
public List<ValidationInfo> getInfos()
- Returns:
- All added
ValidationInfo. The order is maintained.
-
getMessage
public String getMessage()
- Returns:
- A combined message from all
ValidationInfos. The messages are separated by the system default line separator
-
getMessage
public String getMessage(String delimiter)
- Parameters:
delimiter- A custom delimiter which is inserted between messages- Returns:
- A combined message from all
ValidationInfos. The messages are separated by the given delimiter
-
getMessages
public List<String> getMessages()
- Returns:
- A list of all messages from the
ValidationInfos.
-
iterator
public Iterator<ValidationInfo> iterator()
- Specified by:
iteratorin interfaceIterable<ValidationInfo>
-
-