com.netflix.config
Class PropertyWrapper<V>

java.lang.Object
  extended by com.netflix.config.PropertyWrapper<V>
Type Parameters:
V - The type of the DynamicProperty
All Implemented Interfaces:
Property<V>
Direct Known Subclasses:
ChainedDynamicProperty.DynamicBooleanPropertyThatSupportsNull, DynamicBooleanProperty, DynamicContextualProperty, DynamicDoubleProperty, DynamicFloatProperty, DynamicIntProperty, DynamicLongProperty, DynamicStringProperty, StringDerivedProperty

public abstract class PropertyWrapper<V>
extends java.lang.Object
implements Property<V>

A wrapper around DynamicProperty and associates it with a type.


Field Summary
protected  V defaultValue
           
protected  DynamicProperty prop
           
 
Constructor Summary
protected PropertyWrapper(java.lang.String propName, V defaultValue)
           
 
Method Summary
 void addCallback(java.lang.Runnable callback)
          Add the callback to be triggered when the value of the property is changed
 void addValidator(PropertyChangeValidator v)
           
 long getChangedTimestamp()
          Gets the time (in milliseconds past the epoch) when the property was last set/changed.
 V getDefaultValue()
          Get the default property value specified at creation time
 DynamicProperty getDynamicProperty()
           
 java.lang.String getName()
          Get the name of the property
abstract  V getValue()
          Get current typed value of the property.
protected  void propertyChanged()
          Called when the property value is updated.
protected  void propertyChanged(V newValue)
          Called when the property value is updated.
static void registerSubClassWithNoCallback(java.lang.Class<? extends PropertyWrapper> c)
          By default, a subclass of PropertyWrapper will automatically register propertyChanged() as a callback for property value change.
 void removeAllCallbacks()
          Remove all callbacks registered through this instance of property
 java.lang.String toString()
           
protected  void validate(java.lang.String newValue)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

prop

protected final DynamicProperty prop

defaultValue

protected final V defaultValue
Constructor Detail

PropertyWrapper

protected PropertyWrapper(java.lang.String propName,
                          V defaultValue)
Method Detail

registerSubClassWithNoCallback

public static final void registerSubClassWithNoCallback(java.lang.Class<? extends PropertyWrapper> c)
By default, a subclass of PropertyWrapper will automatically register propertyChanged() as a callback for property value change. This method provide a way for a subclass to avoid this overhead if it is not interested to get callback.

Parameters:
c -

getName

public java.lang.String getName()
Description copied from interface: Property
Get the name of the property

Specified by:
getName in interface Property<V>
Returns:
the property name

addValidator

public void addValidator(PropertyChangeValidator v)

propertyChanged

protected void propertyChanged()
Called when the property value is updated. The default does nothing. Subclasses are free to override this if desired.


propertyChanged

protected void propertyChanged(V newValue)
Called when the property value is updated. The default does nothing. Subclasses are free to override this if desired.


validate

protected void validate(java.lang.String newValue)

getChangedTimestamp

public long getChangedTimestamp()
Gets the time (in milliseconds past the epoch) when the property was last set/changed.

Specified by:
getChangedTimestamp in interface Property<V>

addCallback

public void addCallback(java.lang.Runnable callback)
Add the callback to be triggered when the value of the property is changed

Specified by:
addCallback in interface Property<V>
Parameters:
callback -

removeAllCallbacks

public void removeAllCallbacks()
Remove all callbacks registered through this instance of property

Specified by:
removeAllCallbacks in interface Property<V>

getValue

public abstract V getValue()
Get current typed value of the property.

Specified by:
getValue in interface Property<V>
Returns:
the latest property value

getDefaultValue

public V getDefaultValue()
Description copied from interface: Property
Get the default property value specified at creation time

Specified by:
getDefaultValue in interface Property<V>
Returns:
the default property value

getDynamicProperty

public DynamicProperty getDynamicProperty()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object