Class AbstractRangeValidator<R extends Comparable<? super R> & Serializable,​V extends Serializable>

  • Type Parameters:
    R - type of range value
    V - type of validatable
    All Implemented Interfaces:
    Serializable, IComponentAwareEventSink, IComponentAwareHeaderContributor, org.apache.wicket.util.io.IClusterable, IValidator<V>
    Direct Known Subclasses:
    RangeValidator, StringValidator

    public abstract class AbstractRangeValidator<R extends Comparable<? super R> & Serializable,​V extends Serializable>
    extends Behavior
    implements IValidator<V>
    Base class for validators that check if a given value falls within [min,max] range. If either min or max are null they are not checked.

    Resource keys:

    • <class.simpleName>.exact if min==max
    • <class.simpleName>.range if both min and max are not null
    • <class.simpleName>.minimum if max is null
    • <class.simpleName>.maximum if min is null

    Error Message Variables:

    • name: the id of Component that failed
    • label: the label of the Component (either comes from FormComponent.labelModel or resource key <form-id>.<form-component-id>
    • input: the input value
    • minimum: the minimum allowed value
    • maximum: the maximum allowed value

    Author:
    igor
    See Also:
    Serialized Form
    • Constructor Detail

      • AbstractRangeValidator

        public AbstractRangeValidator​(R minimum,
                                      R maximum)
        Constructor that sets the minimum and maximum values.
        Parameters:
        minimum - the minimum value
        maximum - the maximum value
    • Method Detail

      • setRange

        protected final void setRange​(R minimum,
                                      R maximum)
        Sets validator range
        Parameters:
        minimum -
        maximum -
      • getValue

        protected abstract R getValue​(IValidatable<V> validatable)
        Gets the value that should be validated against the range
        Parameters:
        validatable -
        Returns:
        value to validate
      • getMinimum

        public R getMinimum()
        Gets the minimum value.
        Returns:
        minimum value
      • getMaximum

        public R getMaximum()
        Gets the maximum value.
        Returns:
        maximum value
      • getMode

        public final AbstractRangeValidator.Mode getMode()
        Gets validation mode which is determined by whether min, max, or both values are provided
        Returns:
        validation mode