Class WrappingPersister<T>

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method 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.
      java.lang.String interactiveFormat​(T value)
      An exact string representation taking locale and internationalization into account.
      T parseInteractive​(java.lang.String interactiveValue)
      Parse an interactive string.
      T parsePersisted​(java.lang.String persistedValue)
      Parse a persisted string.
      java.lang.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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • WrappingPersister

        protected WrappingPersister​(IPersister<T> delegate)
    • Method Detail

      • persistableString

        public java.lang.String persistableString​(T value)
        Description copied from interface: IPersister
        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. That is, the exact representation must be preserved.
        Specified by:
        persistableString in interface IConstraint<T>
        Specified by:
        persistableString in interface IPersister<T>
        Returns:
        a string representation independent of locale or internationalization.
      • combine

        public IConstraint<T> combine​(IConstraint<?> other)
        Description copied from interface: IConstraint
        Return a constraint that honors both this constraint and other, if such a constraint would accept anything except null. Otherwise, return null.
        Specified by:
        combine in interface IConstraint<T>
        Returns:
        a constraint or null
      • validate

        public boolean validate​(T value)
        Description copied from interface: IConstraint
        Fundamentally, check that 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.
        Specified by:
        validate in interface IConstraint<T>
        Specified by:
        validate in interface IPersister<T>
        Returns:
        true if this value is considered magical and further validation should be skipped, false otherwise. Any return value mean that the value is valid.
      • interactiveFormat

        public java.lang.String interactiveFormat​(T value)
        Description copied from interface: IPersister
        An exact string representation taking locale and internationalization into account. When parsed using IConstraint.parseInteractive(String) (on this instance) yields a result that is equal to the given value. That is, the exact representation must be preserved.
        Specified by:
        interactiveFormat in interface IConstraint<T>
        Specified by:
        interactiveFormat in interface IPersister<T>
        Returns:
        a string representation taking locale and internationalization into account.