Interface IConstraint<T>

    • Method Detail

      • combine

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

        boolean validate​(T value)
                  throws QuantityConversionException
        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.
        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.
        Throws:
        NullPointerException - if value is null and this constraint doesn't allow it
        IllegalArgumentException - if some type aspect of value prevents it from being valid
        QuantityConversionException - if the constraint isn't satisfied in some other way
      • persistableString

        String persistableString​(T value)
                          throws QuantityConversionException
        A string representation independent of locale or internationalization, that when parsed using parsePersisted(String) (on this instance) yields a result that is equal to the given value. That is, the exact representation must be preserved.
        Returns:
        a string representation independent of locale or internationalization.
        Throws:
        NullPointerException - if value is null and this constraint doesn't allow it
        IllegalArgumentException - if some type aspect of value prevents it from being valid
        QuantityConversionException - if the constraint isn't satisfied in some other way