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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addErrorMessage
(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. Ifnull
the message will be ignored
-
hasErrors
public boolean hasErrors()- Returns:
true
if 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 thennull
is returned.This method uses a newline ('\n') character to separate the different error messages.
- Returns:
- An error message or
null
ifhasErrors()
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
null
ifhasErrors()
returnsfalse
-