- java.lang.Object
-
- io.github.mmm.validation.AbstractValidationResult
-
- All Implemented Interfaces:
Localizable
,LocalizableObject
,Composable<ValidationResult>
,ValidationResult
,Iterable<ValidationResult>
- Direct Known Subclasses:
ComposedValidationFailure
,ValidationFailure
public abstract class AbstractValidationResult extends Object implements ValidationResult
Abstract base implementation ofValidationResult
.- Since:
- 1.0.0
-
-
Constructor Summary
Constructors Constructor Description AbstractValidationResult(String code, String source)
The constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
appendCode(Appendable buffer, boolean space)
String
getCode()
String
getSource()
boolean
isValid()
String
toString()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.github.mmm.base.lang.Composable
getChild, getChildCount, iterator
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface io.github.mmm.base.i18n.Localizable
getArgument, getLocalizedMessage, getLocalizedMessage, toLocalizable
-
Methods inherited from interface io.github.mmm.validation.ValidationResult
add, containsCode, getLocalizedMessage, getLocalizedMessage, getLocalizedMessage, getLocalizedMessage, getMessage, getMessage
-
-
-
-
Method Detail
-
isValid
public final boolean isValid()
- Specified by:
isValid
in interfaceValidationResult
- Returns:
true
if the validation was successful,false
otherwise. A successfulValidationResult
is always empty. All other methods will not return any resonable result.
-
getSource
public String getSource()
- Specified by:
getSource
in interfaceValidationResult
- Returns:
- the optional
validation source
describing the origin of thevalue
that has been validated. May benull
. If present this may be the filename where the value was read from, an XPath where the value was located in an XML document, the label of a widget of the UI containing the value, etc. This will help to find the problem easier.
-
getCode
public String getCode()
- Specified by:
getCode
in interfaceValidationResult
- Returns:
- the failure code or
null
ifvalid
. For a singleValidationFailure
this will be theID
of the failingValidator
. The code is a stable identifier that indicates the type of the failure. It can be used for automated testing in order to make the test-cases independent from the actual message texts so they are maintainable and will not break e.g. if typos are fixed in the messages. - See Also:
ComposedValidationFailure.CODE
-
appendCode
protected void appendCode(Appendable buffer, boolean space)
- Parameters:
buffer
- theAppendable
where toappend
thecode
.space
- to append an extra space.
-
-