Package org.voltdb.utils
Class CompoundErrors
java.lang.Object
org.voltdb.utils.CompoundErrors
Helper that can be used to collect multiple errors that are encountered, e.g. while validating the parameters of any
Initializable class. This enables implementing a validation logic that will not stop at the first error, and
return a message compounding multiple error messages.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddErrorMessage(String error) Add a new error message to the set of errors being returned from this validationCreates an error message comprised of all of the error messages added to this instance by callingaddErrorMessage(String).getErrorMessage(String separator) A specialized version ofgetErrorMessage(), using a specific separator.boolean
-
Constructor Details
-
CompoundErrors
public CompoundErrors()
-
-
Method Details
-
addErrorMessage
Add a new error message to the set of errors being returned from this validation- Parameters:
error- message to add. Ifnullthe message will be ignored
-
hasErrors
public boolean hasErrors()- Returns:
trueif errors have been added to this instance
-
getErrorMessage
Creates an error message comprised of all of the error messages added to this instance by callingaddErrorMessage(String). If no error messages were added thennullis returned.This method uses a newline ('\n') character to separate the different error messages.
- Returns:
- An error message or
nullifhasErrors()returnsfalse
-
getErrorMessage
A specialized version ofgetErrorMessage(), using a specific separator.- Parameters:
separator- String separating individual error messages in the final string.- Returns:
- An error message or
nullifhasErrors()returnsfalse
-