|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.iparelan.util.UtilObject
com.iparelan.util.validation.AbstractValidationStrategy<T>
com.iparelan.util.validation.RangeValidationStrategy<T>
T
- The Comparable
type.@Immutable @Copyright(value="Copyright © 2008, Iparelan Solutions, LLC. All rights reserved.") public class RangeValidationStrategy<T extends Comparable<? super T>>
A validator that ensures that a value of a total ordering is within some range of values.
Nested Class Summary | |
---|---|
protected static class |
RangeValidationStrategy.ContextMinMaxIndexOffset
Offsets from the context position where the minimum is specified. |
Nested classes/interfaces inherited from class com.iparelan.util.validation.AbstractValidationStrategy |
---|
AbstractValidationStrategy.ContextIndex |
Field Summary | |
---|---|
private T |
maximum
The stateful maximum range limit. |
private T |
minimum
The stateful minimum range limit. |
Fields inherited from class com.iparelan.util.validation.AbstractValidationStrategy |
---|
valueDescription |
Fields inherited from class com.iparelan.util.UtilObject |
---|
LOGGER, MSGS, UTILITIES_LOGGER_NAME |
Fields inherited from interface com.iparelan.util.validation.ValidationStrategy |
---|
BIG_DECIMAL_RANGE, BIG_INTEGER_RANGE, BYTE_RANGE, CALENDAR_RANGE, CHARACTER_RANGE, DATE_RANGE, DOUBLE_RANGE, FILE, FLOAT_RANGE, GREGORIAN_CALENDAR_RANGE, INTEGER, INTEGER_RANGE, LONG_RANGE, NON_EMPTY_STRING, NON_NULL_CLASS, NON_NULL_NON_EMPTY_STRING, NON_NULL_OBJECT, NON_NULL_STRING, SHORT_RANGE, SQL_DATE_RANGE, SQL_TIME_RANGE, SQL_TIMESTAMP_RANGE |
Constructor Summary | |
---|---|
RangeValidationStrategy()
Creates a RangeValidationStrategy without a stateful value
description or stateful range limits. |
|
RangeValidationStrategy(String valueDescription)
Creates a RangeValidationStrategy with a stateful value
description but without stateful range limits. |
|
RangeValidationStrategy(String valueDescription,
T minimum,
T maximum)
Creates a RangeValidationStrategy with a stateful value
description and stateful range limits. |
|
RangeValidationStrategy(T minimum,
T maximum)
Creates a RangeValidationStrategy without a stateful value
description but with stateful range limits. |
Method Summary | |
---|---|
private T |
getEffectiveValue(RangeValidationStrategy.ContextMinMaxIndexOffset index,
T statefulValue,
Object... context)
Produces the effective value of the selected range limit. |
T |
getMaximum()
Produces the stateful maximum range limit which may be null if
the validation was not created with stateful range limits. |
private T |
getMaximum(Object... context)
Produces the effective range maximum. |
T |
getMinimum()
Produces the stateful minimum range limit which may be null if
the validation was not created with stateful range limits. |
private T |
getMinimum(Object... context)
Produces the effective range minimum. |
String |
getValidatorDescription()
Produces the description of this ValidationStrategy . |
void |
validate(T unvalidated,
Object... context)
Validates the specified value. |
protected void |
validateRangeContext(Object... context)
Ensures that the validation-time context is valid as described by the context parameter of validate(T,
Object...) . |
Methods inherited from class com.iparelan.util.validation.AbstractValidationStrategy |
---|
getValueDescription, getValueDescription, toString, validate |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
@Nullable private final T extends Comparable<? super T> minimum
@Nullable private final T extends Comparable<? super T> maximum
Constructor Detail |
---|
RangeValidationStrategy(T minimum, T maximum)
RangeValidationStrategy
without a stateful value
description but with stateful range limits.
minimum
- The minimum range value. May not be null
.maximum
- The maximum range value. May not be null
.
IllegalArgumentException
- Iff either minimum
or maximum
are null
.RangeValidationStrategy()
RangeValidationStrategy
without a stateful value
description or stateful range limits.
public RangeValidationStrategy(String valueDescription)
RangeValidationStrategy
with a stateful value
description but without stateful range limits.
valueDescription
- The value description of this ValidationStrategy
. May
not be null
.
IllegalArgumentException
- Iff valueDescription is null
or the empty string.public RangeValidationStrategy(String valueDescription, T minimum, T maximum)
RangeValidationStrategy
with a stateful value
description and stateful range limits.
valueDescription
- The value description of this ValidationStrategy
. May
not be null
.minimum
- The minimum range value. May not be null
.maximum
- The maximum range value. May not be null
.
IllegalArgumentException
- Iff either minimum
or maximum
are null
.Method Detail |
---|
public void validate(T unvalidated, Object... context)
unvalidated
- The value to be validated. May not be null
.context
- The context must have one of the following organizations or
unvalidated
cannot be validated:
[value-description : String, minimum : T, maximum :
T]
: Validation may procede regardless of whether the
validator was created with stateful range limit values,
however stateful range limit values take precedence over
contextual range limit values.
[minimum : T, maximum : T]
: Validation may procede
regardless of whether the validator was created with
stateful range limit values, however stateful range limit
values take precedence over contextual range limit values.
[value-description : String]
: The validator must
have been created with stateful range limit values or unvalidated
cannot be validated.
[]
: The validator must have been created with
stateful range limit values or unvalidated
cannot be
validated.
null
: The validator must have been created with
stateful range limit values or unvalidated
cannot be
validated.
ValidationException
- Iff unvalidated
is invalid or cannot be validated
because context
is insufficient.public String getValidatorDescription()
AbstractValidationStrategy
ValidationStrategy
.
getValidatorDescription
in class AbstractValidationStrategy<T extends Comparable<? super T>>
ValidationStrategy
. Never
null
.public T getMinimum()
null
if
the validation was not created with stateful range limits.
null
.public T getMaximum()
null
if
the validation was not created with stateful range limits.
null
.private T getMinimum(Object... context)
context
- As described by validate(T, Object...)
.
null
.
ValidationException
- Iff the effective range minmum cannot be computed because no
stateful range limit minmum is set and the context does not
contain a validation-time range limit minmum.private T getMaximum(Object... context)
context
- As described by validate(T, Object...)
.
null
.
ValidationException
- Iff the effective range maxmum cannot be computed because no
stateful range limit maxmum is set and the context does not
contain a validation-time range limit maxmum.private T getEffectiveValue(RangeValidationStrategy.ContextMinMaxIndexOffset index, @Nullable T statefulValue, Object... context)
index
- Selects the effective range limit value to produce. May not be
null
.statefulValue
- The stateful range limit value, or null
if not is set.context
- The validation-time context that may contain contextual range
limits. May be null
if this validator has stateful range
limits.
null
.
ValidationException
- Iff the context contains range limit values that are not of
type T
, or if the context does not contain any range
limit values and no stateful range limit values are set..protected void validateRangeContext(@Nullable Object... context)
context
parameter of validate(T,
Object...)
. The type of contextual minimum and maximum range limits is
not validated here, see getEffectiveValue(ContextMinMaxIndexOffset, T, Object...)
. Also,
whether stateful minimum and maximum range limits are available in the
absence on contextual limits is not validated here.
context
- The validation-time context to check for validity. See the
context
parameter of validate(T,
Object...)
for valid context organizations. May not be null
.
ValidationException
- Iff the context does not have a proper length or if the context
length indicates that the first element should be a value
description but the first element is not a String
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |