接口 SentinelProperty<T>
- 类型参数:
T- the target type.
- 所有已知实现类:
DynamicSentinelProperty,NoOpSentinelProperty
public interface SentinelProperty<T>
This class holds current value of the config, and is responsible for informing all PropertyListeners
added on this when the config is updated.
Note that not every updateValue(Object newValue) invocation should inform the listeners, only when
newValue is not Equals to the old value, informing is needed.
- 作者:
- Carpenter Lee
-
方法概要
修饰符和类型方法说明voidaddListener(PropertyListener<T> listener) Add aPropertyListenerto thisSentinelProperty.voidremoveListener(PropertyListener<T> listener) Remove thePropertyListeneron this.booleanupdateValue(T newValue) Update thenewValueas the current value of this property and inform allPropertyListeners added on this only when newnewValueis not Equals to the old value.
-
方法详细资料
-
addListener
Add a
PropertyListenerto thisSentinelProperty. After the listener is added,updateValue(Object)will inform the listener if needed.This method can invoke multi times to add more than one listeners.
- 参数:
listener- listener to add.
-
removeListener
Remove thePropertyListeneron this. After removing,updateValue(Object)will not inform the listener.- 参数:
listener- the listener to remove.
-
updateValue
Update thenewValueas the current value of this property and inform allPropertyListeners added on this only when newnewValueis not Equals to the old value.- 参数:
newValue- the new value.- 返回:
- true if the value in property has been updated, otherwise false
-