Class BeanMonitor
java.lang.Object
org.nuiton.util.beans.BeanMonitor
A monitor of beans.
You indicates which properties to monitor (via the constructor).
Then attach a bean to monitor via the method
setBean(Object).
The method clearModified() reset the states about modified
properties.
The method wasModified() tells if there was any modification on
monitored properties for the attached bean since the last call to
clearModified() (or setBean(Object).
the method getModifiedProperties() gives you the names of monitored
properties for the attached bean since the last call to
clearModified() (or setBean(Object).- Since:
- 1.4.1
- Author:
- Tony Chemit - chemit@codelutin.com
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ObjectThe bean to monitor.protected booleanIf true, then listen to the properties which are not in the propertyNamesprotected final PropertyChangeListenerThePropertyChangeListenerwhich listen modification on bean only on monitored properties.protected final Map<String, PropertyDiff> Names of monitored and modified properties for the attached bean.Names of properties to watch or not on attached bean. -
Constructor Summary
ConstructorsConstructorDescriptionBeanMonitor(boolean exclude, String... propertyNames) BeanMonitor(String... propertyNames) Constructor of monitor with property names to monitor. -
Method Summary
Modifier and TypeMethodDescriptionvoidTo clear the modified states.getBean()Obtains the monitoredbean.String[]Obtains the names of monitored properties which has been touched for the attached bean since last call toclearModified()orsetBean(Object).Obtains the original values for all modified properties.Obtains the property diffs since the bean is monitoried.booleanvoidSets thebeanto monitor.voidsetExcludeMode(boolean excludeMode) voidsetProperties(String... properties) To change the list of properties to watch.booleanTells if any of the monitored properties were modified on the attached bean since last call toclearModified()orsetBean(Object).
-
Field Details
-
propertyNames
-
excludeMode
protected boolean excludeModeIf true, then listen to the properties which are not in the propertyNames -
propertyDiffs
Names of monitored and modified properties for the attached bean. -
listener
ThePropertyChangeListenerwhich listen modification on bean only on monitored properties. -
bean
The bean to monitor.
-
-
Constructor Details
-
BeanMonitor
Constructor of monitor with property names to monitor.- Parameters:
propertyNames- the names of properties to monitor
-
BeanMonitor
-
-
Method Details
-
getBean
-
wasModified
public boolean wasModified()Tells if any of the monitored properties were modified on the attached bean since last call toclearModified()orsetBean(Object).- Returns:
trueif there were a modified monitored property on the attached bean,falseotherwise.
-
getModifiedProperties
Obtains the names of monitored properties which has been touched for the attached bean since last call toclearModified()orsetBean(Object).- Returns:
- the array of property names to monitor.
-
getOriginalValues
-
getPropertyDiffs
Obtains the property diffs since the bean is monitoried.- Returns:
- the property diffs since the bean is monitoried.
- Since:
- 2.4
-
setBean
Sets thebeanto monitor. As a side effect, it will attach thelistenerto new bean (if not null) and remove it from the previous bean attached (if not null). As a second side effect, it will always clean the modified states, using the methodclearModified().- Parameters:
bean- the new bean to monitor
-
clearModified
public void clearModified()To clear the modified states. -
setProperties
To change the list of properties to watch. Note: As a side-effect, we call aclearModified()method after having changed the list of properties to watch.- Parameters:
properties- the list of properties to watch on the bean.- Since:
- 3.0
-
isExcludeMode
public boolean isExcludeMode() -
setExcludeMode
public void setExcludeMode(boolean excludeMode)
-