|
||||||||||
| 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>
@Immutable @Copyright(value="Copyright © 2008, Iparelan Solutions, LLC. All rights reserved.") public abstract class AbstractValidationStrategy<T>
Provides logic common to all validation strategies.
| Nested Class Summary | |
|---|---|
protected static class |
AbstractValidationStrategy.ContextIndex
The default position of the value description in the validation context. |
| Field Summary | |
|---|---|
protected String |
valueDescription
The value description of this validation strategy. |
| 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 | |
|---|---|
(package private) |
AbstractValidationStrategy()
Creates an AbstractValidationStrategy. |
protected |
AbstractValidationStrategy(String valueDescription)
Creates an AbstractValidationStrategy. |
| Method Summary | |
|---|---|
abstract String |
getValidatorDescription()
Produces the description of this ValidationStrategy. |
String |
getValueDescription()
Produces the description of the values that are validated. |
protected String |
getValueDescription(Object... context)
A convenience routine that fetches the creation-time (constructor argument) value description if one was provided, otherwise fetches a value description from the provided context, if the context contains a value description, otherwise produces the empty string. |
private Object[] |
mergeContext(String valueDescription,
Object... context)
Produces a new context by prepending valueDescription to context. |
String |
toString()
|
protected void |
validate(T unvalidated,
String valueDescription,
Object... context)
Invokes ValidationStrategy.validate(T, Object...) after prepending valueDescription to context. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface com.iparelan.util.validation.ValidationStrategy |
|---|
validate |
| Field Detail |
|---|
protected final String valueDescription
| Constructor Detail |
|---|
AbstractValidationStrategy()
AbstractValidationStrategy. Only members of this
package may create a ValidationStrategy without an explicit
value description. This is allows self-explanatory, general-purpose
validators to be created by component implementers, but requires
application programmers to provide a value description.
protected AbstractValidationStrategy(String valueDescription)
AbstractValidationStrategy.
valueDescription - The value description of this ValidationStrategy. May
not be null or the empty string.
IllegalArgumentException - Iff valueDescription is either null or the
empty string.| Method Detail |
|---|
protected final void validate(T unvalidated,
String valueDescription,
Object... context)
ValidationStrategy.validate(T, Object...) after prepending valueDescription to context. This operation is useful in the
validate method of validator subtypes that are implemented by composing
other validators. The composed validators are given access to the value
description by invoking this form of validate.
unvalidated - See ValidationStrategy.validate(T, Object...).valueDescription - A description of the value being validated that is prepended to
context. May not be null or the empty string.context - See ValidationStrategy.validate(T, Object...).
ValidationException - See ValidationStrategy.validate(T, Object...).public final String getValueDescription()
null.public abstract String getValidatorDescription()
ValidationStrategy.
ValidationStrategy. Never
null.public final String toString()
toString in class Objectprotected final String getValueDescription(Object... context)
context - Any information required for, or related to, the validation of
unvalidated. The exact semantics of this parameter are
defined by the override of this method. May be omitted or null.
null, but
may be the empty string.
private Object[] mergeContext(String valueDescription,
Object... context)
valueDescription to context.
valueDescription - The value description to prepend to context. May not be
null or the empty string.context - The context to which valueDescription is prepended. May
not be null.
valueDescription prepended to context. Never null.
IllegalArgumentException - Iff valueDescription is either null or the
empty string.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||