com.netflix.config
Class DynamicListProperty<T>

java.lang.Object
  extended by com.netflix.config.DynamicListProperty<T>
All Implemented Interfaces:
Property<java.util.List<T>>
Direct Known Subclasses:
DynamicStringListProperty

public abstract class DynamicListProperty<T>
extends java.lang.Object
implements Property<java.util.List<T>>

This class delegates to a regex (default is comma) delimited dynamic string property and returns a dynamic list of a generic type which is transformed from string.


Field Summary
static java.lang.String DEFAULT_DELIMITER
           
 
Constructor Summary
DynamicListProperty(java.lang.String propName, java.util.List<T> defaultValue)
           
DynamicListProperty(java.lang.String propName, java.util.List<T> defaultValue, com.google.common.base.Splitter splitter)
          Create the dynamic list property using the splitter and default list value passed in from the arguments.
DynamicListProperty(java.lang.String propName, java.util.List<T> defaultValue, java.lang.String delimiterRegex)
          Create the dynamic list property.
DynamicListProperty(java.lang.String propName, java.lang.String defaultValue)
          Create the dynamic list property using default delimiter regex ",".
DynamicListProperty(java.lang.String propName, java.lang.String defaultValue, java.lang.String delimiterRegex)
          Create the dynamic list property.
 
Method Summary
 void addCallback(java.lang.Runnable callback)
          Add the callback to be triggered when the value of the property is changed
protected abstract  T from(java.lang.String value)
          Construct the generic type from string.
 java.util.List<T> get()
          Get the list type from the underlying dynamic string property.
 long getChangedTimestamp()
          Gets the time (in milliseconds past the epoch) when the property was last set/changed.
 java.util.List<T> getDefaultValue()
          Get the default property value specified at creation time
 java.lang.String getName()
          Getter for the property name
 java.util.List<T> getValue()
          Get the latest value for the given property
protected  void load()
           
protected  void propertyChanged()
          A method invoked when the underlying string property is changed.
 void removeAllCallbacks()
          Remove all callbacks registered through this instance of property
protected  java.util.List<T> transform(java.util.List<java.lang.String> stringValues)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_DELIMITER

public static final java.lang.String DEFAULT_DELIMITER
See Also:
Constant Field Values
Constructor Detail

DynamicListProperty

public DynamicListProperty(java.lang.String propName,
                           java.lang.String defaultValue)
Create the dynamic list property using default delimiter regex ",". The guava Splitter used is created as Splitter.onPattern(delimiterRegex).omitEmptyStrings().trimResults(). The default list value will be transformed from list of strings after splitting. If defaultValue string is null, the default list value will be an empty list.


DynamicListProperty

public DynamicListProperty(java.lang.String propName,
                           java.lang.String defaultValue,
                           java.lang.String delimiterRegex)
Create the dynamic list property. The guava Splitter used is created as Splitter.onPattern(delimiterRegex).omitEmptyStrings().trimResults(). The default list value will be transformed from list of strings after splitting. If defaultValue string is null, the default list value will be an empty list.


DynamicListProperty

public DynamicListProperty(java.lang.String propName,
                           java.util.List<T> defaultValue)

DynamicListProperty

public DynamicListProperty(java.lang.String propName,
                           java.util.List<T> defaultValue,
                           java.lang.String delimiterRegex)
Create the dynamic list property. The guava Splitter used is created as Splitter.onPattern(delimiterRegex).omitEmptyStrings().trimResults(). The default list value will be taken from the passed in list argument.


DynamicListProperty

public DynamicListProperty(java.lang.String propName,
                           java.util.List<T> defaultValue,
                           com.google.common.base.Splitter splitter)
Create the dynamic list property using the splitter and default list value passed in from the arguments.

Method Detail

propertyChanged

protected void propertyChanged()
A method invoked when the underlying string property is changed. Default implementation does nothing. Subclass can override this method to receive callback.


get

public java.util.List<T> get()
Get the list type from the underlying dynamic string property. If the property is undefined, this method returns the default list value.


getValue

public java.util.List<T> getValue()
Description copied from interface: Property
Get the latest value for the given property

Specified by:
getValue in interface Property<java.util.List<T>>
Returns:
the latest property value

getDefaultValue

public java.util.List<T> getDefaultValue()
Description copied from interface: Property
Get the default property value specified at creation time

Specified by:
getDefaultValue in interface Property<java.util.List<T>>
Returns:
the default property value

transform

protected java.util.List<T> transform(java.util.List<java.lang.String> stringValues)

load

protected void load()

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<java.util.List<T>>

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<java.util.List<T>>

removeAllCallbacks

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

Specified by:
removeAllCallbacks in interface Property<java.util.List<T>>

from

protected abstract T from(java.lang.String value)
Construct the generic type from string.


getName

public java.lang.String getName()
Getter for the property name

Specified by:
getName in interface Property<java.util.List<T>>
Returns:
the property name