public abstract class WrappingPersister<T> extends Object implements IPersister<T>
Modifier | Constructor and Description |
---|---|
protected |
WrappingPersister(IPersister<T> delegate) |
Modifier and Type | Method and Description |
---|---|
IConstraint<T> |
combine(IConstraint<?> other)
Return a constraint that honors both this constraint and
other , if such a constraint
would accept anything except null . |
String |
interactiveFormat(T value)
An exact string representation taking locale and internationalization into account.
|
T |
parseInteractive(String interactiveValue)
Parse an interactive string.
|
T |
parsePersisted(String persistedValue)
Parse a persisted string.
|
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. |
protected WrappingPersister(IPersister<T> delegate)
public String persistableString(T value)
IPersister
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>
persistableString
in interface IPersister<T>
public T parsePersisted(String persistedValue) throws QuantityConversionException
IConstraint
IConstraint.persistableString(Object)
on this instance. Only use this on persisted strings,
never for interactive input.parsePersisted
in interface IConstraint<T>
QuantityConversionException
- if persistedValue
couldn't be parsed or didn't satisfy the constraintpublic IConstraint<T> combine(IConstraint<?> other)
IConstraint
other
, if such a constraint
would accept anything except null
. Otherwise, return null
.combine
in interface IConstraint<T>
null
public T parseInteractive(String interactiveValue) throws QuantityConversionException
IConstraint
IConstraint.interactiveFormat(Object)
on this instance and in the same locale. Only use this for
interactive input, never for persisted strings.parseInteractive
in interface IConstraint<T>
QuantityConversionException
- if interactiveValue
couldn't be parsed or didn't satisfy the constraintpublic boolean validate(T value)
IConstraint
value
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>
validate
in interface IPersister<T>
value
is valid.public String interactiveFormat(T value)
IPersister
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>
interactiveFormat
in interface IPersister<T>
Copyright © 2020. All rights reserved.