接口 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
  • 方法详细资料

    • addListener

      void addListener(PropertyListener<T> listener)

      Add a PropertyListener to this SentinelProperty. 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

      void removeListener(PropertyListener<T> listener)
      Remove the PropertyListener on this. After removing, updateValue(Object) will not inform the listener.
      参数:
      listener - the listener to remove.
    • updateValue

      boolean updateValue(T newValue)
      Update the newValue as the current value of this property and inform all PropertyListeners added on this only when new newValue is not Equals to the old value.
      参数:
      newValue - the new value.
      返回:
      true if the value in property has been updated, otherwise false