- java.lang.Object
-
- io.github.mmm.validation.ValidationResultValid
-
- All Implemented Interfaces:
Localizable
,LocalizableObject
,Composable<ValidationResult>
,ValidationResult
,Iterable<ValidationResult>
public final class ValidationResultValid extends Object implements ValidationResult
ValidationResult
that isvalid
.- Since:
- 1.0.0
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ValidationResult
add(ValidationResult result)
static ValidationResultValid
get()
String
getCode()
String
getLocalizedMessage()
String
getLocalizedMessage(Locale locale)
This method gets the resolved and localized message.void
getLocalizedMessage(Locale locale, Appendable buffer, boolean verbose)
String
getMessage()
ATTENTION:
In most cases you wand to useLocalizable.getLocalizedMessage(Locale)
instead of this method.String
getSource()
boolean
isValid()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, 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, toLocalizable
-
Methods inherited from interface io.github.mmm.validation.ValidationResult
containsCode, getLocalizedMessage, getLocalizedMessage, getLocalizedMessage, getMessage
-
-
-
-
Method Detail
-
isValid
public 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.
-
getMessage
public String getMessage()
Description copied from interface:Localizable
ATTENTION:
In most cases you wand to useLocalizable.getLocalizedMessage(Locale)
instead of this method.- Specified by:
getMessage
in interfaceLocalizable
- Specified by:
getMessage
in interfaceValidationResult
- Returns:
- the untranslated message with arguments filled in. This results in the message in its original language that should typically be English.
- See Also:
ValidationResult.getMessage(boolean)
-
getLocalizedMessage
public String getLocalizedMessage()
Description copied from interface:Localizable
This method tries to get thelocalized message
asString
using thedefault locale
. ATTENTION:
If possible try to avoid using this method and useLocalizable.getLocalizedMessage(Locale)
instead (e.g. using springLocaleContextHolder
to get the users locale).- Specified by:
getLocalizedMessage
in interfaceLocalizable
- Returns:
- the localized message.
-
getLocalizedMessage
public String getLocalizedMessage(Locale locale)
Description copied from interface:Localizable
This method gets the resolved and localized message.- Specified by:
getLocalizedMessage
in interfaceLocalizable
- Parameters:
locale
- is the locale to translate to.- Returns:
- the localized message.
-
getLocalizedMessage
public void getLocalizedMessage(Locale locale, Appendable buffer, boolean verbose)
- Specified by:
getLocalizedMessage
in interfaceValidationResult
- Parameters:
locale
- is theLocale
to translate to.buffer
- theAppendable
where towrite
the message to.verbose
- the verbose flag (to includecode
(s), etc.- See Also:
ValidationResult.getLocalizedMessage(Locale, Appendable)
-
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
-
add
public ValidationResult add(ValidationResult result)
- Specified by:
add
in interfaceValidationResult
- Parameters:
result
- anotherValidationResult
to combine with this one.- Returns:
- the
ValidationResult
composed out of this with the givenresult
. - See Also:
ValidationResultBuilder
-
get
public static ValidationResultValid get()
- Returns:
- the singleton instance of this class.
-
-