Package io.guise.framework.validator
Class IntegerRangeValidator
- java.lang.Object
-
- com.globalmentor.beans.BoundPropertyObject
-
- io.guise.framework.event.GuiseBoundPropertyObject
-
- io.guise.framework.validator.AbstractValidator<V>
-
- io.guise.framework.validator.AbstractRangeValidator<V>
-
- io.guise.framework.validator.AbstractComparableRangeValidator<java.lang.Integer>
-
- io.guise.framework.validator.IntegerRangeValidator
-
- All Implemented Interfaces:
com.globalmentor.beans.PropertyBindable
,com.globalmentor.beans.PropertyConstrainable
,RangeValidator<java.lang.Integer>
,Validator<java.lang.Integer>
public class IntegerRangeValidator extends AbstractComparableRangeValidator<java.lang.Integer>
A range validator for integers. The step value is considered relative either to the minimum value, if available, the maximum value, if available, or zero, in that order or priority.- Author:
- Garret Wilson
-
-
Field Summary
-
Fields inherited from class com.globalmentor.beans.BoundPropertyObject
NO_PROPERTY_CHANGE_LISTENERS, NO_VETOABLE_CHANGE_LISTENERS
-
Fields inherited from interface io.guise.framework.validator.Validator
INVALID_VALUE_MESSAGE_PROPERTY, VALUE_REQUIRED_MESSAGE_PROPERTY, VALUE_REQUIRED_PROPERTY
-
-
Constructor Summary
Constructors Constructor Description IntegerRangeValidator()
Default constructor with no value required and a step of one.IntegerRangeValidator(boolean valueRequired)
Value required constructor with a step of one.IntegerRangeValidator(java.lang.Integer maximum)
Maximum constructor with a minimum value of zero and a step of one.IntegerRangeValidator(java.lang.Integer maximum, boolean valueRequired)
Minimum and value required constructor with a minimum value of zero and a step of one.IntegerRangeValidator(java.lang.Integer minimum, java.lang.Integer maximum)
Minimum and maximum constructor with a step of one.IntegerRangeValidator(java.lang.Integer minimum, java.lang.Integer maximum, boolean valueRequired)
Minimum, maximum, and value required constructor with a step of one.IntegerRangeValidator(java.lang.Integer minimum, java.lang.Integer maximum, java.lang.Integer step)
Minimum, maximum, and step constructor.IntegerRangeValidator(java.lang.Integer minimum, java.lang.Integer maximum, java.lang.Integer step, boolean valueRequired)
Minimum, maximum, step, and value required constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
isValidStep(java.lang.Integer value, java.lang.Integer step, java.lang.Integer base)
Determines whether the given value falls on the correct step amount relative to the base value.-
Methods inherited from class io.guise.framework.validator.AbstractComparableRangeValidator
validate
-
Methods inherited from class io.guise.framework.validator.AbstractRangeValidator
getMaximum, getMinimum, getStep
-
Methods inherited from class io.guise.framework.validator.AbstractValidator
getInvalidValueMessage, getValueRequiredMessage, isValid, isValueRequired, setInvalidValueMessage, setValueRequired, setValueRequiredMessage, throwInvalidValueValidationException, throwValueRequiredValidationException, toString
-
Methods inherited from class io.guise.framework.event.GuiseBoundPropertyObject
getSession
-
Methods inherited from class com.globalmentor.beans.BoundPropertyObject
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, createPostponedPropertyChangeEvent, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, getForwardPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeSupport, getRepeatPropertyChangeListener, getRepeatVetoableChangeListener, getVetoableChangeListeners, getVetoableChangeListeners, getVetoableChangeSupport, hasPropertyChangeListeners, hasVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.globalmentor.beans.PropertyBindable
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, hasPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
Methods inherited from interface io.guise.framework.validator.Validator
getInvalidValueMessage, getSession, getValueRequiredMessage, isValid, setInvalidValueMessage, setValueRequiredMessage
-
-
-
-
Constructor Detail
-
IntegerRangeValidator
public IntegerRangeValidator()
Default constructor with no value required and a step of one.
-
IntegerRangeValidator
public IntegerRangeValidator(boolean valueRequired)
Value required constructor with a step of one.- Parameters:
valueRequired
- Whether the value must be non-null
in order to be considered valid.
-
IntegerRangeValidator
public IntegerRangeValidator(java.lang.Integer maximum)
Maximum constructor with a minimum value of zero and a step of one.- Parameters:
maximum
- The maximum value, inclusive, ornull
if the range has no upper bound.
-
IntegerRangeValidator
public IntegerRangeValidator(java.lang.Integer minimum, java.lang.Integer maximum)
Minimum and maximum constructor with a step of one.- Parameters:
minimum
- The minimum value, inclusive, ornull
if the range has no lower bound.maximum
- The maximum value, inclusive, ornull
if the range has no upper bound.
-
IntegerRangeValidator
public IntegerRangeValidator(java.lang.Integer minimum, java.lang.Integer maximum, java.lang.Integer step)
Minimum, maximum, and step constructor.- Parameters:
minimum
- The minimum value, inclusive, ornull
if the range has no lower bound.maximum
- The maximum value, inclusive, ornull
if the range has no upper bound.step
- The step amount, ornull
if the range has no increment value specified.
-
IntegerRangeValidator
public IntegerRangeValidator(java.lang.Integer maximum, boolean valueRequired)
Minimum and value required constructor with a minimum value of zero and a step of one.- Parameters:
maximum
- The maximum value, inclusive, ornull
if the range has no upper bound.valueRequired
- Whether the value must be non-null
in order to be considered valid.
-
IntegerRangeValidator
public IntegerRangeValidator(java.lang.Integer minimum, java.lang.Integer maximum, boolean valueRequired)
Minimum, maximum, and value required constructor with a step of one.- Parameters:
minimum
- The minimum value, inclusive, ornull
if the range has no lower bound.maximum
- The maximum value, inclusive, ornull
if the range has no upper bound.valueRequired
- Whether the value must be non-null
in order to be considered valid.
-
IntegerRangeValidator
public IntegerRangeValidator(java.lang.Integer minimum, java.lang.Integer maximum, java.lang.Integer step, boolean valueRequired)
Minimum, maximum, step, and value required constructor.- Parameters:
minimum
- The minimum value, inclusive, ornull
if the range has no lower bound.maximum
- The maximum value, inclusive, ornull
if the range has no upper bound.step
- The step amount, ornull
if the range has no increment value specified.valueRequired
- Whether the value must be non-null
in order to be considered valid.
-
-
Method Detail
-
isValidStep
protected boolean isValidStep(java.lang.Integer value, java.lang.Integer step, java.lang.Integer base)
Description copied from class:AbstractComparableRangeValidator
Determines whether the given value falls on the correct step amount relative to the base value.- Specified by:
isValidStep
in classAbstractComparableRangeValidator<java.lang.Integer>
- Parameters:
value
- The value to validate.step
- The step value.base
- The base (either the minimum or maximum value), ornull
if zero should be used as a base.- Returns:
true
if the value is a valid step away from the given base.
-
-