com.netflix.config
Class DynamicSetProperty<T>

java.lang.Object
  extended by com.netflix.config.DynamicSetProperty<T>
All Implemented Interfaces:
Property<java.util.Set<T>>
Direct Known Subclasses:
DynamicStringSetProperty

public abstract class DynamicSetProperty<T>
extends java.lang.Object
implements Property<java.util.Set<T>>


Field Summary
static java.lang.String DEFAULT_DELIMITER
           
 
Constructor Summary
DynamicSetProperty(java.lang.String propName, java.util.Set<T> defaultValue)
           
DynamicSetProperty(java.lang.String propName, java.util.Set<T> defaultValue, com.google.common.base.Splitter splitter)
          Create the dynamic set property using the splitter and default set value passed in from the arguments.
DynamicSetProperty(java.lang.String propName, java.util.Set<T> defaultValue, java.lang.String delimiterRegex)
          Create the dynamic set property.
DynamicSetProperty(java.lang.String propName, java.lang.String defaultValue)
          Create the dynamic set property using default delimiter regex ",".
DynamicSetProperty(java.lang.String propName, java.lang.String defaultValue, java.lang.String delimiterRegex)
          Create the dynamic set 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.Set<T> get()
          Get the set 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.Set<T> getDefaultValue()
          Get the default property value specified at creation time
 java.lang.String getName()
          Getter for the property name
 java.util.Set<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.Set<T> transform(java.util.Set<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

DynamicSetProperty

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


DynamicSetProperty

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


DynamicSetProperty

public DynamicSetProperty(java.lang.String propName,
                          java.util.Set<T> defaultValue)

DynamicSetProperty

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


DynamicSetProperty

public DynamicSetProperty(java.lang.String propName,
                          java.util.Set<T> defaultValue,
                          com.google.common.base.Splitter splitter)
Create the dynamic set property using the splitter and default set 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.Set<T> get()
Get the set type from the underlying dynamic string property. If the property is undefined, this method returns the default set value.


getValue

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

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

getDefaultValue

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

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

transform

protected java.util.Set<T> transform(java.util.Set<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.Set<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.Set<T>>

removeAllCallbacks

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

Specified by:
removeAllCallbacks in interface Property<java.util.Set<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.Set<T>>
Returns:
the property name