Package org.openjdk.jmc.common.unit
Interface IPersister<T>
-
- All Superinterfaces:
IConstraint<T>
- All Known Implementing Classes:
KindOfQuantity,LinearKindOfQuantity,WrappingPersister
public interface IPersister<T> extends IConstraint<T>
A specializedconstraintthat allows all instances ofT, but notnull. As a result,interactiveFormat(Object)andpersistableString(Object)cannot throwQuantityConversionException, butNullPointerExceptionand in some casesIllegalArgumentException. This interface is typically implemented bycontent typeswhere every allowed value readily can be represented with a human editable string.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description StringinteractiveFormat(T value)An exact string representation taking locale and internationalization into account.StringpersistableString(T value)A string representation independent of locale or internationalization, that when parsed usingIConstraint.parsePersisted(String)(on this instance) yields a result that isequalto the givenvalue.booleanvalidate(T value)Fundamentally, check thatvaluesatisfies this constraint and throw an exception otherwise.-
Methods inherited from interface org.openjdk.jmc.common.unit.IConstraint
combine, parseInteractive, parsePersisted
-
-
-
-
Method Detail
-
validate
boolean validate(T value)
Description copied from interface:IConstraintFundamentally, check thatvaluesatisfies this constraint and throw an exception otherwise. As long as the method returns normally,valueis 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.- Specified by:
validatein interfaceIConstraint<T>- Returns:
- true if this value is considered magical and further validation should be skipped,
false otherwise. Any return value mean that the
valueis valid.
-
persistableString
String persistableString(T value)
A string representation independent of locale or internationalization, that when parsed usingIConstraint.parsePersisted(String)(on this instance) yields a result that isequalto the givenvalue. That is, the exact representation must be preserved.- Specified by:
persistableStringin interfaceIConstraint<T>- Returns:
- a string representation independent of locale or internationalization.
- Throws:
NullPointerException- ifvalueis nullIllegalArgumentException- if some type aspect ofvalueprevents it from being valid
-
interactiveFormat
String interactiveFormat(T value)
An exact string representation taking locale and internationalization into account. When parsed usingIConstraint.parseInteractive(String)(on this instance) yields a result that isequalto the givenvalue. That is, the exact representation must be preserved.- Specified by:
interactiveFormatin interfaceIConstraint<T>- Returns:
- a string representation taking locale and internationalization into account.
- Throws:
NullPointerException- ifvalueis nullIllegalArgumentException- if some type aspect ofvalueprevents it from being valid
-
-