public class BasicChangeTracker extends Object implements ChangeTracker
Explicit change recording (i.e. using markChange()) works as intended. A new mode,
implicit change recording, works as follows:
TR is an instance of BasicChangeTracker.Prop in object A and XXX is its type.NV is a new value for that property.A.setProp(TR.updateXXX(A.getProp(), NV)updateXXX group of methods determine whether the new value is different from
the old value. If there is a difference, the change is recorded. In any case, the new value
is returned and may be fed into an appropriate property setter.| Modifier | Constructor and Description |
|---|---|
protected |
BasicChangeTracker(boolean enablePropertyGathering)
Instantiates a new change tracker with optional recording of
changed properties.
|
| Modifier and Type | Method and Description |
|---|---|
static BasicChangeTracker |
gatheringPropertyNames()
Creates a new instance of change tracker that records names of changed
properties.
|
int |
getChangeCount()
Determines number of detected changes
|
Set<String> |
getChangedProperties()
Returns a set of changed property names.
|
boolean |
isChanged()
Determines whether any change has happened so far.
|
void |
markChange()
Marks a change without specific binding to a named property.
|
void |
markChange(String propertyName)
Marks a change in a named property.
|
void |
resetChanges()
Reset the tracker to initial state, where there are no changes
recorded.
|
static BasicChangeTracker |
simple()
Creates a new instance of change tracked that does not record names
of changed properties.
|
boolean |
updateBoolean(boolean origValue,
boolean newValue)
Equivalent of
updateBoolean(origValue, newValue, null). |
boolean |
updateBoolean(boolean origValue,
boolean newValue,
String propertyName)
Implicitly records a change of the given property if the provided original
and new values are different.
|
byte |
updateByte(byte origValue,
byte newValue)
Equivalent of
updateByte(origValue, newValue, null). |
byte |
updateByte(byte origValue,
byte newValue,
String propertyName)
Implicitly records a change of the given property if the provided original
and new values are different.
|
int |
updateInt(int origValue,
int newValue)
Equivalent of
updateInt(origValue, newValue, null). |
int |
updateInt(int origValue,
int newValue,
String propertyName)
Implicitly records a change of the given property if the provided original
and new values are different.
|
long |
updateLong(long origValue,
long newValue)
Equivalent of
updateLong(origValue, newValue, null). |
long |
updateLong(long origValue,
long newValue,
String propertyName)
Implicitly records a change of the given property if the provided original
and new values are different.
|
<T> T |
updateObject(T origValue,
T newValue)
Equivalent of
updateObject(origValue, newValue, null). |
<T> T |
updateObject(T origValue,
T newValue,
String propertyName)
Implicitly records a change of the given property if the provided original
and new values are different.
|
short |
updateShort(short origValue,
short newValue)
Equivalent of
updateShort(origValue, newValue, null). |
short |
updateShort(short origValue,
short newValue,
String propertyName)
Implicitly records a change of the given property if the provided original
and new values are different.
|
String |
updateString(String origValue,
String newValue)
Equivalent of
updateString(origValue, newValue, null). |
String |
updateString(String origValue,
String newValue,
String propertyName)
Implicitly records a change of the given property if the provided original
and new values are different.
|
protected BasicChangeTracker(boolean enablePropertyGathering)
enablePropertyGathering - enables recording of changed property namespublic static BasicChangeTracker simple()
public static BasicChangeTracker gatheringPropertyNames()
public void resetChanges()
ChangeTrackerresetChanges in interface ChangeTrackerpublic boolean isChanged()
ChangeTrackerisChanged in interface ChangeTrackertrue if a change was recordedpublic int getChangeCount()
ChangeTrackergetChangeCount in interface ChangeTrackerpublic Set<String> getChangedProperties()
ChangeTrackergetChangedProperties in interface ChangeTrackerpublic void markChange()
ChangeTrackermarkChange in interface ChangeTrackerpublic void markChange(String propertyName)
ChangeTrackermarkChange in interface ChangeTrackerpropertyName - name of changed propertypublic int updateInt(int origValue,
int newValue)
updateInt(origValue, newValue, null).origValue - original value of some propertynewValue - new value for the propertypublic int updateInt(int origValue,
int newValue,
String propertyName)
origValue - original value of property with name specified by propertyNamenewValue - new value for the propertypropertyName - name of the manipulated propertypublic short updateShort(short origValue,
short newValue)
updateShort(origValue, newValue, null).origValue - original value of some propertynewValue - new value for the propertypublic short updateShort(short origValue,
short newValue,
String propertyName)
origValue - original value of property with name specified by propertyNamenewValue - new value for the propertypropertyName - name of the manipulated propertypublic long updateLong(long origValue,
long newValue)
updateLong(origValue, newValue, null).origValue - original value of some propertynewValue - new value for the propertypublic long updateLong(long origValue,
long newValue,
String propertyName)
origValue - original value of property with name specified by propertyNamenewValue - new value for the propertypropertyName - name of the manipulated propertypublic byte updateByte(byte origValue,
byte newValue)
updateByte(origValue, newValue, null).origValue - original value of some propertynewValue - new value for the propertypublic byte updateByte(byte origValue,
byte newValue,
String propertyName)
origValue - original value of property with name specified by propertyNamenewValue - new value for the propertypropertyName - name of the manipulated propertypublic boolean updateBoolean(boolean origValue,
boolean newValue)
updateBoolean(origValue, newValue, null).origValue - original value of some propertynewValue - new value for the propertypublic boolean updateBoolean(boolean origValue,
boolean newValue,
String propertyName)
origValue - original value of property with name specified by propertyNamenewValue - new value for the propertypropertyName - name of the manipulated propertypublic String updateString(String origValue, String newValue)
updateString(origValue, newValue, null).origValue - original value of some propertynewValue - new value for the propertypublic String updateString(String origValue, String newValue, String propertyName)
origValue - original value of property with name specified by propertyNamenewValue - new value for the propertypropertyName - name of the manipulated propertypublic <T> T updateObject(T origValue,
T newValue)
updateObject(origValue, newValue, null).origValue - original value of some propertynewValue - new value for the propertypublic <T> T updateObject(T origValue,
T newValue,
String propertyName)
T - type of the manipulated propertyorigValue - original value of property with name specified by propertyNamenewValue - new value for the propertypropertyName - name of the manipulated propertyCopyright © 2014 Boleslav Bobcik - Auderis. All rights reserved.