public class BeanMonitor extends Object
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)
.Modifier and Type | Field and Description |
---|---|
protected Object |
bean
The bean to monitor.
|
protected boolean |
excludeMode
If true, then listen to the properties which are not in the propertyNames
|
protected PropertyChangeListener |
listener
The
PropertyChangeListener which listen modification on bean
only on monitored properties. |
protected Map<String,PropertyDiff> |
propertyDiffs
Names of monitored and modified properties for the attached bean.
|
protected List<String> |
propertyNames
Names of properties to watch or not on attached bean.
|
Constructor and Description |
---|
BeanMonitor(boolean exclude,
String... propertyNames) |
BeanMonitor(String... propertyNames)
Constructor of monitor with property names to monitor.
|
Modifier and Type | Method and Description |
---|---|
void |
clearModified()
To clear the modified states.
|
Object |
getBean()
Obtains the monitored
bean . |
String[] |
getModifiedProperties()
Obtains the names of monitored properties which has been touched for the
attached bean since last call to
clearModified() or
setBean(Object) . |
Map<String,Object> |
getOriginalValues()
Obtains the original values for all modified properties.
|
PropertyDiff[] |
getPropertyDiffs()
Obtains the property diffs since the bean is monitoried.
|
boolean |
isExcludeMode() |
void |
setBean(Object bean)
Sets the
bean to monitor. |
void |
setExcludeMode(boolean excludeMode) |
void |
setProperties(String... properties)
To change the list of properties to watch.
|
boolean |
wasModified()
Tells if any of the monitored properties were modified on the attached
bean since last call to
clearModified() or
setBean(Object) . |
protected final List<String> propertyNames
protected boolean excludeMode
protected final Map<String,PropertyDiff> propertyDiffs
protected final PropertyChangeListener listener
PropertyChangeListener
which listen modification on bean
only on monitored properties.protected Object bean
public BeanMonitor(String... propertyNames)
propertyNames
- the names of properties to monitorpublic BeanMonitor(boolean exclude, String... propertyNames)
public Object getBean()
bean
.null
if none attached.public boolean wasModified()
clearModified()
or
setBean(Object)
.true
if there were a modified monitored property on
the attached bean, false
otherwise.public String[] getModifiedProperties()
clearModified()
or
setBean(Object)
.public Map<String,Object> getOriginalValues()
public PropertyDiff[] getPropertyDiffs()
public void setBean(Object bean)
bean
to monitor.
As a side effect, it will attach the listener
to 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 method clearModified()
.bean
- the new bean to monitorpublic void clearModified()
public void setProperties(String... properties)
clearModified()
method after having changed the list of
properties to watch.properties
- the list of properties to watch on the bean.public boolean isExcludeMode()
public void setExcludeMode(boolean excludeMode)
Copyright © 2004–2020 CodeLutin. All rights reserved.