java.beans
abstract class: java_util_Collections [javadoc |
source]
java.lang.Object
java.beans.PersistenceDelegate
java.beans.java_util_Collections
Direct Known Subclasses:
CheckedCollection_PersistenceDelegate, CheckedList_PersistenceDelegate, CheckedSortedMap_PersistenceDelegate, SynchronizedCollection_PersistenceDelegate, SynchronizedSortedMap_PersistenceDelegate, UnmodifiableMap_PersistenceDelegate, UnmodifiableSet_PersistenceDelegate, CheckedSortedSet_PersistenceDelegate, SynchronizedRandomAccessList_PersistenceDelegate, UnmodifiableCollection_PersistenceDelegate, SingletonMap_PersistenceDelegate, UnmodifiableRandomAccessList_PersistenceDelegate, CheckedMap_PersistenceDelegate, SingletonList_PersistenceDelegate, EmptySet_PersistenceDelegate, CheckedSet_PersistenceDelegate, EmptyList_PersistenceDelegate, UnmodifiableSortedSet_PersistenceDelegate, UnmodifiableList_PersistenceDelegate, SynchronizedMap_PersistenceDelegate, SynchronizedSortedSet_PersistenceDelegate, EmptyMap_PersistenceDelegate, CheckedRandomAccessList_PersistenceDelegate, SingletonSet_PersistenceDelegate, UnmodifiableSortedMap_PersistenceDelegate, SynchronizedList_PersistenceDelegate, SynchronizedSet_PersistenceDelegate
The base class for persistence delegates for inner classes
that can be created using
Collections .
- author:
Sergey - A. Malenkov
| Methods from java.lang.Object: |
|---|
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method from java.beans.java_util_Collections Detail: |
static Object getPrivateField(Object instance,
String name) {
return AccessController.doPrivileged(
new PrivilegedAction() {
public Object run() {
Class type = instance.getClass();
while ( true ) {
try {
Field field = type.getDeclaredField(name);
field.setAccessible(true);
return field.get( instance );
}
catch (NoSuchFieldException exception) {
type = type.getSuperclass();
if (type == null) {
throw new IllegalStateException("Could not find field " + name, exception);
}
}
catch (Exception exception) {
throw new IllegalStateException("Could not get value " + type.getName() + '." + name, exception);
}
}
}
} );
}
|
protected boolean mutatesTo(Object oldInstance,
Object newInstance) {
if (!super.mutatesTo(oldInstance, newInstance)) {
return false;
}
if ((oldInstance instanceof List) || (oldInstance instanceof Set) || (oldInstance instanceof Map)) {
return oldInstance.equals(newInstance);
}
Collection oldC = (Collection) oldInstance;
Collection newC = (Collection) newInstance;
return (oldC.size() == newC.size()) && oldC.containsAll(newC);
}
|