Class BooleanProperty
java.lang.Object
com.iohao.net.common.kit.beans.property.BooleanProperty
- All Implemented Interfaces:
PropertyValueObservable<Boolean>
bool - Property has listening feature. A listening event will be triggered when the value changes.
var property = new BooleanProperty();
// add listener monitor property object
property.addListener((observable, oldValue, newValue) -> {
log.info("oldValue:{}, newValue:{}", oldValue, newValue);
});
property.get(); // value is false
property.set(true); // When the value changes,listeners are triggered
property.get(); // value is true
- Author:
- 渔民小镇
- date:
- 2024-04-17
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(PropertyChangeListener<? super Boolean> listener) Register a change listener to be notified when the value changes.voidchange()Change the boolean valuebooleanget()get current valuegetValue()Get the current property value.protected voidMark the property as invalid and fire change events to all registered listeners.voidremoveListener(PropertyChangeListener<? super Boolean> listener) Remove a previously registered change listener.voidset(boolean newValue) set current valuevoidSet the property value, triggering listeners if the value changed.toString()
-
Field Details
-
valid
protected boolean valid
-
-
Constructor Details
-
BooleanProperty
public BooleanProperty() -
BooleanProperty
public BooleanProperty(boolean 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 boolean get()get current value- Returns:
- current value
-
set
public void set(boolean newValue) set current value- Parameters:
newValue- current new value
-
change
public void change()Change the boolean value -
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.
-