public interface IPersister<T> extends IConstraint<T>
constraint that allows all instances of T, but not
null. As a result, interactiveFormat(Object) and
persistableString(Object) cannot throw QuantityConversionException, but
NullPointerException and in some cases IllegalArgumentException. This interface
is typically implemented by content types where every allowed value readily
can be represented with a human editable string.| Modifier and Type | Method and Description |
|---|---|
String |
interactiveFormat(T value)
An exact string representation taking locale and internationalization into account.
|
String |
persistableString(T value)
A string representation independent of locale or internationalization, that when parsed using
IConstraint.parsePersisted(String) (on this instance) yields a result that is
equal to the given value. |
boolean |
validate(T value)
Fundamentally, check that
value satisfies this constraint and throw an exception
otherwise. |
combine, parseInteractive, parsePersistedboolean validate(T value)
IConstraintvalue satisfies this constraint and throw an exception
otherwise. As long as the method returns normally, value is a valid value, regardless
of the return value. However, when wrapping a persister in a constraint, it is possible that
the persister treats some magic values differently. If the constraint isn't aware of these
magical values it should typically not try to validate them. This is signaled by the
persister by returning true from this method.validate in interface IConstraint<T>value is valid.String persistableString(T value)
IConstraint.parsePersisted(String) (on this instance) yields a result that is
equal to the given value. That is, the exact
representation must be preserved.persistableString in interface IConstraint<T>NullPointerException - if value is nullIllegalArgumentException - if some type aspect of value prevents it from being validString interactiveFormat(T value)
IConstraint.parseInteractive(String) (on this instance) yields a result that is
equal to the given value. That is, the exact
representation must be preserved.interactiveFormat in interface IConstraint<T>NullPointerException - if value is nullIllegalArgumentException - if some type aspect of value prevents it from being validCopyright © 2019. All rights reserved.