org.springframework.binding.value.support
Class DefaultValueChangeDetector
java.lang.Object
org.springframework.binding.value.support.DefaultValueChangeDetector
- All Implemented Interfaces:
- ValueChangeDetector
public class DefaultValueChangeDetector
- extends Object
- implements ValueChangeDetector
Implementation of ValueChangeDetector that maintains a set of classes for which it is
"safe" to use equals()
for detecting a change in value (those classes
that have immutable values). For all objects of a type in this set, the value
comparison will be done using equals. For all other types, object equivalence (the ==
operator) will be used.
This is the default value change detector handed out by the Application Services.
- Author:
- Larry Streepy
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
classesWithSafeEquals
protected final Set classesWithSafeEquals
DefaultValueChangeDetector
public DefaultValueChangeDetector()
hasValueChanged
public boolean hasValueChanged(Object oldValue,
Object newValue)
- Determines if there has been a change in value between the provided arguments. As
many objects do not implement #equals in a manner that is strict enough for the
requirements of this class, difference is determined using
!=
,
however, to improve accuracy #equals will be used when this is definitely safe e.g.
for Strings, Booleans, Numbers, Dates.
- Specified by:
hasValueChanged
in interface ValueChangeDetector
- Parameters:
oldValue
- Original object valuenewValue
- New object value
- Returns:
- true if the objects are different enough to indicate a change in the value
model
setClassesWithSafeEquals
public void setClassesWithSafeEquals(Collection classes)
- Specify the set of classes that have an equals method that is safe to use for
determining a value change.
- Parameters:
classes
- with safe equals methods
getClassesWithSafeEquals
public Collection getClassesWithSafeEquals()
- Get the set of classes that have an equals method that is safe to use for
determining a value change.
- Returns:
- Collection of classes with safe equals methods
Copyright © 2004-2008 The Spring Framework. All Rights Reserved.