|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.threerings.antidote.field.BaseFieldWrapper<F>
abstract class BaseFieldWrapper<F extends ReferenceField>
A base class for common FieldWrapper
functionality.
Package private. Use one of the subclasses.
RequiredField
,
OptionalField
Constructor Summary | |
---|---|
BaseFieldWrapper(Class<? extends Field> clazz,
Field parent)
Construct a FieldWrapper which expects the wrapped Field to be set later
using setField(F) . |
|
BaseFieldWrapper(F wrapped,
Field parent)
Construct a FieldWrapper by providing the already constructed Field to be
wrapped and the parent Field which holds the wrapped Field . |
|
BaseFieldWrapper(String abstractName,
Field parent)
Construct a FieldWrapper which expects the wrapped Field to be set later
using setField(F) . |
Method Summary | |
---|---|
protected void |
appendViolation(Violation violation)
Add a violation to the list of violations returned when this Field is validated. |
protected void |
appendViolationList(List<Violation> violations)
Add a list of violations to the list of violations returned when this Field is validated. |
F |
getField()
Returns the Field held by this FieldWrapper . |
String |
getFieldName()
Returns the unique name of this Field. |
Location |
getLocation()
Provide the location of the wrapped Field if it is set, otherwise use the parent
Field location, which will be a good estimate. |
Field |
getParent()
Return the parent Field of the wrapped Field . |
boolean |
isNotSet()
Returns true if the Mutable data contained in this object is not set, e.g. |
boolean |
isSet()
Returns true if the Mutable data contained in this object is set, e.g. |
void |
setField(F wrapped)
Set the wrapped Field . |
List<Violation> |
validate()
Validates the object, returning a list of Violation classes for any validation violations. |
protected abstract void |
validateWrappedField()
Provide subclasses a chance to perform additional validation, including validation of the wrapped field. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BaseFieldWrapper(F wrapped, Field parent)
FieldWrapper
by providing the already constructed Field
to be
wrapped and the parent Field
which holds the wrapped Field
.
wrapped
- The Field
to be wrapped.parent
- The wrapped Field
parent.
IllegalArgumentException
- If either wrapped or parent is null.public BaseFieldWrapper(Class<? extends Field> clazz, Field parent)
FieldWrapper
which expects the wrapped Field
to be set later
using setField(F)
. The Class
of the wrapped Field
is provided
so that the name of the Field
can be determined. The parent Field
which
holds the wrapped Field
is also provided.
parent
- The wrapped Field
parent.
IllegalArgumentException
- If parent is null.public BaseFieldWrapper(String abstractName, Field parent)
FieldWrapper
which expects the wrapped Field
to be set later
using setField(F)
. This constructor should be used for abstract Field
classes where the name of the field cannot be known until a concrete class is constructed
via the Ant setter or added method. The name of the abstract Field
class is provided
to be used for the field name until the wrapped field is set. The parent Field
which
holds the wrapped Field
is also provided.
abstractName
- The name of the abstract Field
to be wrapped.parent
- The wrapped Field
parent.
IllegalArgumentException
- If parent or abstractName is null.Method Detail |
---|
public void setField(F wrapped)
FieldWrapper
Field
. Provided so that the wrapped Field
may be set
whenever an Ant setter method is called, which may be after this FieldWrapper
was
constructed. It is a violation to set the wrapped Field
more than once and the
FieldWrapper
will fail in RequiresValidation.validate()
.
setField
in interface FieldWrapper<F extends ReferenceField>
public F getField()
FieldWrapper
Field
held by this FieldWrapper
. If the held Field
is set
that object will be returned. If the Field
is set and is a Reference
to
another Field
, the referenced Field
will be returned. Finally, if the Field
is not set, RequiresValidationException
will be thrown. Use Mutable.isSet()
or
Mutable.isNotSet()
to determine the status of the held Field
before calling
this method.
getField
in interface FieldWrapper<F extends ReferenceField>
public Field getParent()
FieldWrapper
Field
of the wrapped Field
.
getParent
in interface FieldWrapper<F extends ReferenceField>
public String getFieldName()
Field
getFieldName
in interface Field
public Location getLocation()
Field
if it is set, otherwise use the parent
Field
location, which will be a good estimate.
getLocation
in interface Field
public boolean isSet()
Mutable
Mutable
data contained in this object is set, e.g. not null.
False otherwise.
isSet
in interface Mutable
public boolean isNotSet()
Mutable
Mutable
data contained in this object is not set, e.g. null.
False otherwise.
isNotSet
in interface Mutable
public final List<Violation> validate()
RequiresValidation
Violation
classes for any validation violations.
validate
in interface RequiresValidation
protected void appendViolation(Violation violation)
Field
is validated.
protected void appendViolationList(List<Violation> violations)
Field
is validated.
protected abstract void validateWrappedField()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |