Class LongProperty
java.lang.Object
com.iohao.net.common.kit.beans.property.LongProperty
- All Implemented Interfaces:
PropertyValueObservable<Number>
long - Property has listening feature. A listening event will be triggered when the value changes.
var property = new LongProperty();
// add listener monitor property object
property.addListener((observable, oldValue, newValue) -> {
log.info("oldValue:{}, newValue:{}", oldValue, newValue);
});
property.get(); // value is 0
property.set(22); // When the value changes,listeners are triggered
property.get(); // value is 22
- Author:
- 渔民小镇
- date:
- 2024-04-17
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(PropertyChangeListener<? super Number> listener) Register a change listener to be notified when the value changes.voidcurrent value - 1longget()get current valuegetValue()Get the current property value.voidcurrent value + 1protected voidMark the property as invalid and fire change events to all registered listeners.voidremoveListener(PropertyChangeListener<? super Number> listener) Remove a previously registered change listener.voidset(long newValue) set current valuevoidSet the property value, triggering listeners if the value changed.toString()
-
Field Details
-
valid
protected boolean valid
-
-
Constructor Details
-
LongProperty
public LongProperty() -
LongProperty
public LongProperty(long value)
-
-
Method Details
-
getValue
Description copied from interface:PropertyValueObservableGet the current property value.- Returns:
- the current value
-
setValue
Description copied from interface:PropertyValueObservableSet the property value, triggering listeners if the value changed.- Parameters:
value- the new value to set
-
get
public long get()get current value- Returns:
- current value
-
set
public void set(long newValue) set current value- Parameters:
newValue- current new value
-
increment
public void increment()current value + 1 -
decrement
public void decrement()current value - 1 -
toString
-
addListener
Description copied from interface:PropertyValueObservableRegister a change listener to be notified when the value changes.- Specified by:
addListenerin interfacePropertyValueObservable<T>- Parameters:
listener- the listener to register
-
removeListener
Description copied from interface:PropertyValueObservableRemove a previously registered change listener.- Specified by:
removeListenerin interfacePropertyValueObservable<T>- Parameters:
listener- the listener to remove
-
markInvalid
protected void markInvalid()Mark the property as invalid and fire change events to all registered listeners.
-