com.threerings.antidote.property
Class BaseProperty<T>

java.lang.Object
  extended by com.threerings.antidote.property.BaseProperty<T>
All Implemented Interfaces:
Mutable, Property<T>, RequiresValidation
Direct Known Subclasses:
BooleanProperty, EnumProperty, FileProperty, IntegerProperty, ListProperty, ModeProperty, StringProperty, URLProperty

public abstract class BaseProperty<T>
extends Object
implements Property<T>, RequiresValidation

A base implementation for Property objects to extend from. Generic type indicates the type of object being held by the property after validation.


Constructor Summary
BaseProperty(String name, Field field)
          Construct a new BaseProperty.
BaseProperty(String name, Field field, T defaultValue)
          Construct a new BaseProperty with a default value.
 
Method Summary
protected  void appendViolation(Violation violation)
          Add a violation to the list of violations returned when this Property is validated.
 Field getField()
          Returns the Field this Property is attached to.
 String getPropertyName()
          Returns the unique name of this field property.
protected  String getRawValue()
          Provides concrete classes access to the raw user value.
 T getValue()
          Returns the value assigned to this property, after it has been validated from the raw value.
 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 setValue(String value)
          Sets the raw String value of the property.
 List<Violation> validate()
          Implement validate() in the base abstract class ensuring correct behavior.
protected abstract  T validateProperty()
          Give each Property a chance to do property specific validation and return the validated value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseProperty

public BaseProperty(String name,
                    Field field)
Construct a new BaseProperty.

Parameters:
name - The name of this property.
field - The Field holding this property.

BaseProperty

public BaseProperty(String name,
                    Field field,
                    T defaultValue)
Construct a new BaseProperty with a default value.

Parameters:
name - The name of this property.
field - The Field holding this property.
defaultValue - The default value for the field.
Method Detail

getPropertyName

public final String getPropertyName()
Description copied from interface: Property
Returns the unique name of this field property.

Specified by:
getPropertyName in interface Property<T>

getField

public final Field getField()
Description copied from interface: Property
Returns the Field this Property is attached to.

Specified by:
getField in interface Property<T>

getValue

public final T getValue()
Description copied from interface: Property
Returns the value assigned to this property, after it has been validated from the raw value.

Specified by:
getValue in interface Property<T>

isSet

public boolean isSet()
Description copied from interface: Mutable
Returns true if the Mutable data contained in this object is set, e.g. not null. False otherwise.

Specified by:
isSet in interface Mutable

isNotSet

public boolean isNotSet()
Description copied from interface: Mutable
Returns true if the Mutable data contained in this object is not set, e.g. null. False otherwise.

Specified by:
isNotSet in interface Mutable

validate

public final List<Violation> validate()
Implement validate() in the base abstract class ensuring correct behavior. Provide accessors to the list of violations in protected methods.

Specified by:
validate in interface RequiresValidation
See Also:
appendViolation(Violation)

setValue

public final void setValue(String value)
Sets the raw String value of the property. It is intended that this method would be called from an Ant setter method.


validateProperty

protected abstract T validateProperty()
Give each Property a chance to do property specific validation and return the validated value. If the raw value could not turned into a valid value, this will return null.


appendViolation

protected void appendViolation(Violation violation)
Add a violation to the list of violations returned when this Property is validated.


getRawValue

protected final String getRawValue()
Provides concrete classes access to the raw user value.



Copyright © 2007-2008 Three Rings Design, Inc. All Rights Reserved. Released under a BSD license.