- 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
ValidationResultthat isvalid.- Since:
- 1.0.0
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ValidationResultadd(ValidationResult result)static ValidationResultValidget()StringgetCode()StringgetLocalizedMessage()StringgetLocalizedMessage(Locale locale)This method gets the resolved and localized message.voidgetLocalizedMessage(Locale locale, Appendable buffer, boolean verbose)StringgetMessage()ATTENTION:
In most cases you wand to useLocalizable.getLocalizedMessage(Locale)instead of this method.StringgetSource()booleanisValid()-
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:
isValidin interfaceValidationResult- Returns:
trueif the validation was successful,falseotherwise. A successfulValidationResultis always empty. All other methods will not return any resonable result.
-
getSource
public String getSource()
- Specified by:
getSourcein interfaceValidationResult- Returns:
- the optional
validation sourcedescribing the origin of thevaluethat 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:LocalizableATTENTION:
In most cases you wand to useLocalizable.getLocalizedMessage(Locale)instead of this method.- Specified by:
getMessagein interfaceLocalizable- Specified by:
getMessagein 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:LocalizableThis method tries to get thelocalized messageasStringusing thedefault locale. ATTENTION:
If possible try to avoid using this method and useLocalizable.getLocalizedMessage(Locale)instead (e.g. using springLocaleContextHolderto get the users locale).- Specified by:
getLocalizedMessagein interfaceLocalizable- Returns:
- the localized message.
-
getLocalizedMessage
public String getLocalizedMessage(Locale locale)
Description copied from interface:LocalizableThis method gets the resolved and localized message.- Specified by:
getLocalizedMessagein 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:
getLocalizedMessagein interfaceValidationResult- Parameters:
locale- is theLocaleto translate to.buffer- theAppendablewhere towritethe message to.verbose- the verbose flag (to includecode(s), etc.- See Also:
ValidationResult.getLocalizedMessage(Locale, Appendable)
-
getCode
public String getCode()
- Specified by:
getCodein interfaceValidationResult- Returns:
- the failure code or
nullifvalid. For a singleValidationFailurethis will be theIDof 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:
addin interfaceValidationResult- Parameters:
result- anotherValidationResultto combine with this one.- Returns:
- the
ValidationResultcomposed out of this with the givenresult. - See Also:
ValidationResultBuilder
-
get
public static ValidationResultValid get()
- Returns:
- the singleton instance of this class.
-
-