summaryrefslogtreecommitdiff
path: root/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control
diff options
context:
space:
mode:
authorBenjamin Culkin <scorpress@gmail.com>2024-07-01 17:27:48 -0400
committerBenjamin Culkin <scorpress@gmail.com>2024-07-01 17:27:48 -0400
commit02bc52037e9ccccca672d6156d9c325c74fe28b3 (patch)
treedb022b83c90562f461f4a27412caa9936a8dfd04 /projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control
parentc75d7dbd613a47b217499f7a856c469a8bc59e2a (diff)
Update a whole bunch of things
Yeah... not a great commit message. t.b.h, I could maybe've split the commit into more parts; but that would be quite a lot off effort and would have a pretty decent chance of at least one of the commits leaving the repository in a non-working state. For the future, will want to try and commit more often so there aren't these mega-commits where it's just "a whole bunch of stuff changed"
Diffstat (limited to 'projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control')
-rw-r--r--projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/AbstractObjectStore.java25
-rw-r--r--projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EOClassDescription.java57
-rw-r--r--projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EOCooperatingObjectStore.java2
-rw-r--r--projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EOEditingContext.java161
-rw-r--r--projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EOFaultHandler.java4
-rw-r--r--projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EOKeyValueCodingAdditions.java14
-rw-r--r--projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EOObjectStore.java4
-rw-r--r--projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EOObjectStoreCoordinator.java2
-rw-r--r--projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EOTemporaryGlobalID.java2
9 files changed, 155 insertions, 116 deletions
diff --git a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/AbstractObjectStore.java b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/AbstractObjectStore.java
index 1989582..d47d86b 100644
--- a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/AbstractObjectStore.java
+++ b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/AbstractObjectStore.java
@@ -70,18 +70,19 @@ public abstract class AbstractObjectStore extends EOObjectStore {
/**
* This implementation returns an appropriately configured array fault.
*/
- public NSArray arrayFaultWithSourceGlobalID(EOGlobalID aGlobalID, String aRelationship, EOEditingContext aContext) { // System.out.println(
- // "arrayFaultWithSourceGlobalID:
- // "
- // +
- // aGlobalID
- // +
- // "
- // :
- // "
- // +
- // aRelationship
- // );
+ public NSArray arrayFaultWithSourceGlobalID(EOGlobalID aGlobalID, String aRelationship, EOEditingContext aContext) {
+ // System.out.println(
+ // "arrayFaultWithSourceGlobalID:
+ // "
+ // +
+ // aGlobalID
+ // +
+ // "
+ // :
+ // "
+ // +
+ // aRelationship
+ // );
return new ArrayFault(aGlobalID, aRelationship, aContext);
}
diff --git a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EOClassDescription.java b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EOClassDescription.java
index 79019de..c4425cb 100644
--- a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EOClassDescription.java
+++ b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EOClassDescription.java
@@ -36,7 +36,7 @@ import net.wotonomy.foundation.internal.WotonomyException;
* The default implementation works for most well-formed java beans, but you
* will want to create your own subclass most typically to customize the toOne
* and toMany relationships for your class to ensure that an entire graph of
- * objects is not persisted in order to perist a single object. <br>
+ * objects is not persisted in order to persist a single object. <br>
* <br>
*
* The easiest way to register your subclass is to create it in the same package
@@ -53,7 +53,7 @@ import net.wotonomy.foundation.internal.WotonomyException;
* @author $Author: cgruber $
* @version $Revision: 900 $
*/
-public class EOClassDescription {
+public class EOClassDescription<C> {
/**
* A delete rule specifying that object(s) that reference this object should
* have those references set to null when this object is deleted.
@@ -67,7 +67,7 @@ public class EOClassDescription {
public static final int DeleteRuleCascade = 1;
/**
- * A delete rule specicying that this object should not be allowed to be deleted
+ * A delete rule specifying that this object should not be allowed to be deleted
* if it references any object(s).
*/
public static final int DeleteRuleDeny = 2;
@@ -110,24 +110,25 @@ public class EOClassDescription {
* still not found, a class description is returned that uses java bean
* introspection to provide reasonable values.
*/
- public static EOClassDescription classDescriptionForClass(Class aClass) {
+ @SuppressWarnings("unchecked")
+ public static <C> EOClassDescription<C> classDescriptionForClass(Class<C> aClass) {
if (classMap == null)
- classMap = new HashMap();
- EOClassDescription result = (EOClassDescription) classMap.get(aClass);
+ classMap = new HashMap<>();
+ EOClassDescription<C> result = (EOClassDescription<C>) classMap.get(aClass);
if (result == null) {
// if not found, post notification
NSNotificationCenter.defaultCenter().postNotification(ClassDescriptionNeededForClassNotification, aClass,
null);
- result = (EOClassDescription) classMap.get(aClass);
+ result = (EOClassDescription<C>) classMap.get(aClass);
}
if (result == null) {
// if not found, look for similarly named class
String className = aClass.getName() + ClassNameSuffix;
- Class classDesc;
+ Class<EOClassDescription<C>> classDesc;
try {
- classDesc = aClass.getClassLoader().loadClass(className);
+ classDesc = (Class<EOClassDescription<C>>) aClass.getClassLoader().loadClass(className);
if (classDesc != null) {
- result = (EOClassDescription) classDesc.newInstance();
+ result = classDesc.getDeclaredConstructor().newInstance();
registerClassDescription(result, aClass);
}
} catch (Exception exc) {
@@ -136,7 +137,7 @@ public class EOClassDescription {
}
if (result == null) {
// if not found, default to this class
- result = new EOClassDescription(aClass);
+ result = new EOClassDescription<>(aClass);
registerClassDescription(result, aClass);
}
return result;
@@ -148,15 +149,16 @@ public class EOClassDescription {
* ClassDescriptionNeededForEntityNameNotification is posted. Returns null if no
* class description can be found for the entity name.
*/
- public static EOClassDescription classDescriptionForEntityName(String aName) {
+ @SuppressWarnings("unchecked")
+ public static <C> EOClassDescription<C> classDescriptionForEntityName(String aName) {
if (entityMap == null)
- entityMap = new HashMap();
- EOClassDescription result = (EOClassDescription) entityMap.get(aName);
+ entityMap = new HashMap<>();
+ EOClassDescription<C> result = (EOClassDescription<C>) entityMap.get(aName);
if (result == null) {
// if not found, post notification
NSNotificationCenter.defaultCenter().postNotification(ClassDescriptionNeededForEntityNameNotification,
aName, null);
- result = (EOClassDescription) entityMap.get(aName);
+ result = (EOClassDescription<C>) entityMap.get(aName);
}
return result;
}
@@ -171,14 +173,14 @@ public class EOClassDescription {
}
/**
- * Registers the specified class descriptiong for the specified class. Nulls are
+ * Registers the specified class description for the specified class. Nulls are
* not allowed - to clear the cache call invalidateClassDescriptionCache().
*/
- public static void registerClassDescription(EOClassDescription description, Class aClass) {
+ public static <C> void registerClassDescription(EOClassDescription<C> description, Class<C> aClass) {
if (classMap == null)
- classMap = new HashMap();
+ classMap = new HashMap<>();
if (entityMap == null)
- entityMap = new HashMap();
+ entityMap = new HashMap<>();
description.theClass = aClass;
classMap.put(aClass, description);
entityMap.put(description.entityName(), description);
@@ -198,16 +200,16 @@ public class EOClassDescription {
*/
private final static String ClassNameSuffix = "ClassDesc";
- private static Map classMap;
- private static Map entityMap;
+ private static Map<Class<?>, EOClassDescription<?>> classMap;
+ private static Map<String, EOClassDescription<?>> entityMap;
- protected Class theClass;
+ protected Class<?> theClass;
private NSMutableArray attributes;
/**
* Constructor may only be called by subclasses.
*/
- protected EOClassDescription(Class aClass) {
+ protected EOClassDescription(Class<?> aClass) {
theClass = aClass;
}
@@ -265,7 +267,7 @@ public class EOClassDescription {
* relationship key, or null if the class description cannot be determined for
* that key. This implementation returns null.
*/
- public EOClassDescription classDescriptionForDestinationKey(String detailKey) {
+ public EOClassDescription<?> classDescriptionForDestinationKey(String detailKey) {
return null;
}
@@ -280,11 +282,12 @@ public class EOClassDescription {
* editing context is specified, the global id is ignored and the new instance
* of the class is returned.
*/
- public Object createInstanceWithEditingContext(EOEditingContext anEditingContext, EOGlobalID globalID) {
+ @SuppressWarnings("unchecked")
+ public C createInstanceWithEditingContext(EOEditingContext anEditingContext, EOGlobalID globalID) {
//System.out.println( "createInstanceWithEditingContext: " + this + " : " + theClass );
Object result = null;
try {
- result = theClass.newInstance();
+ result = theClass.getDeclaredConstructor().newInstance();
if (anEditingContext != null) {
if (globalID != null) {
if (result instanceof EOEnterpriseObject) {
@@ -305,7 +308,7 @@ public class EOClassDescription {
// error instantiating
throw new WotonomyException(exc);
}
- return result;
+ return (C) result;
}
/*
diff --git a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EOCooperatingObjectStore.java b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EOCooperatingObjectStore.java
index 98a8a60..552e6b8 100644
--- a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EOCooperatingObjectStore.java
+++ b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EOCooperatingObjectStore.java
@@ -59,8 +59,10 @@ public abstract class EOCooperatingObjectStore extends EOObjectStore implements
public abstract NSDictionary valuesForKeys(NSArray nsarray, EOEnterpriseObject eoenterpriseobject);
+ @Override
public abstract void lock();
+ @Override
public abstract void unlock();
}
diff --git a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EOEditingContext.java b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EOEditingContext.java
index 3a39035..8342722 100644
--- a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EOEditingContext.java
+++ b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EOEditingContext.java
@@ -89,23 +89,24 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
private EOObjectStore parentStore;
private WeakReference delegate;
private WeakReference messageHandler;
- private List editorSet;
+ private List<WeakReference<EOEditingContext.Editor>> editorSet;
private double fetchTimestamp;
private boolean lockBeforeModify;
private boolean propagateDeletesAfterEvent;
private boolean stopValidationAfterError;
- private NSMutableArray insertedObjects;
- private NSMutableArray insertedObjectsBuffer;
- private NSArray insertedObjectsProxy;
- private NSMutableArray updatedObjects;
- private NSMutableArray updatedObjectsBuffer;
- private NSArray updatedObjectsProxy;
- private NSMutableArray deletedObjects;
- private NSMutableArray deletedObjectsBuffer;
- private NSArray deletedObjectsProxy;
- private NSMutableArray deletedIDsBuffer;
- private NSMutableArray invalidatedObjectsBuffer;
- private NSMutableArray invalidatedIDsBuffer;
+ private NSMutableArray<Object> insertedObjects;
+ private NSMutableArray<Object> insertedObjectsBuffer;
+ private NSArray<Object> insertedObjectsProxy;
+ private NSMutableArray<Object> updatedObjects;
+ private NSMutableArray<Object> updatedObjectsBuffer;
+ private NSArray<Object> updatedObjectsProxy;
+ private NSMutableArray<Object> deletedObjects;
+ private NSMutableArray<Object> deletedObjectsBuffer;
+ private NSArray<Object> deletedObjectsProxy;
+ // TODO I think this is EOGlobalID but not certain
+ private NSMutableArray<Object> deletedIDsBuffer;
+ private NSMutableArray<Object> invalidatedObjectsBuffer;
+ private NSMutableArray<EOGlobalID> invalidatedIDsBuffer;
private Registrar registrar;
// private UndoManager undoManager;
@@ -143,7 +144,7 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
parentStore = anObjectStore;
delegate = null;
messageHandler = null;
- editorSet = new LinkedList();
+ editorSet = new LinkedList<>();
fetchTimestamp = 0;
lockBeforeModify = false;
propagateDeletesAfterEvent = true;
@@ -189,10 +190,10 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
* Registers the specified object as an editor for this context. The object is
* expected to implement EOEditingContext.Editor.
*/
- public void addEditor(Object anEditor) {
+ public void addEditor(EOEditingContext.Editor anEditor) {
if (anEditor == null)
return;
- editorSet.add(new WeakReference(anEditor));
+ editorSet.add(new WeakReference<>(anEditor));
}
/**
@@ -205,6 +206,7 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
* specified relationship key must produce a result of type Collection for the
* source object or an exception is thrown.
*/
+ @Override
public NSArray arrayFaultWithSourceGlobalID(EOGlobalID aGlobalID, String aRelationshipKey,
EOEditingContext aContext) {
NSArray result = null;
@@ -337,6 +339,7 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
* Called by child editing contexts when they no longer need to track the
* specified id. This implementation forwards the call to the parent store.
*/
+ @Override
public void editingContextDidForgetObjectWithGlobalID(EOEditingContext aContext, EOGlobalID aGlobalID) {
parentStore.editingContextDidForgetObjectWithGlobalID(aContext, aGlobalID);
}
@@ -347,9 +350,9 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
public NSArray editors() {
NSMutableArray result = new NSMutableArray();
Object o;
- Iterator i = editorSet.iterator();
+ Iterator<WeakReference<Editor>> i = editorSet.iterator();
while (i.hasNext()) {
- o = ((WeakReference) i.next()).get();
+ o = i.next().get();
if (o != null) {
result.addObject(o);
} else {
@@ -370,6 +373,7 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
* create a copy of the object and register it in the specified context.
* Otherwise it will forward the call to the parent object store.
*/
+ @Override
public /* EOEnterpriseObject */ Object faultForGlobalID(EOGlobalID aGlobalID, EOEditingContext aContext) {
Object result = registrar.objectForGlobalID(aGlobalID);
@@ -402,6 +406,7 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
* specified editing context. This implementation forwards the call to the
* parent store.
*/
+ @Override
public /* EOEnterpriseObject */ Object faultForRawRow(Map aDictionary, String anEntityName,
EOEditingContext aContext) {
return parentStore.faultForRawRow(aDictionary, anEntityName, aContext);
@@ -461,11 +466,10 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
/**
* Returns an array of ids for an array of objects.
*/
- private NSArray globalIDsForObjects(List anObjectList) {
+ private NSArray globalIDsForObjects(List<Object> anObjectList) {
NSMutableArray result = new NSMutableArray();
- Iterator it = anObjectList.iterator();
- while (it.hasNext()) {
- result.add(globalIDForObject(it.next()));
+ for (Object obj : anObjectList) {
+ result.add(globalIDForObject(obj));
}
return result;
}
@@ -492,6 +496,7 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
* in this editing context if possible, calling to the parent object store only
* if such an object is not found.
*/
+ @Override
public void initializeObject(/* EOEnterpriseObject */ Object anObject, EOGlobalID aGlobalID,
EOEditingContext aContext) {
Object existingObject = registrar.objectForGlobalID(aGlobalID);
@@ -539,6 +544,7 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
deletedObjects.removeObjectAtIndex(index);
// if in the deleted ids buffer
+ // TODO is this
index = deletedIDsBuffer.indexOfIdenticalObject(anObject);
if (index != NSArray.NotFound) {
// remove from deleted ids buffer
@@ -587,6 +593,7 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
* fetched the next time they are accessed, and calls
* invalidateObjectsWithGlobalIDs on the parent object store.
*/
+ @Override
public void invalidateAllObjects() {
// register change so processRecentChanges is called
willChange();
@@ -613,9 +620,9 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
// refault all objects
EOGlobalID id;
Object o;
- Enumeration e = ids.objectEnumerator();
+ Enumeration<EOGlobalID> e = ids.objectEnumerator();
while (e.hasMoreElements()) {
- id = (EOGlobalID) e.nextElement();
+ id = e.nextElement();
o = objectForGlobalID(id);
// some objects may have been manually discarded
@@ -645,6 +652,7 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
* fetched the next time they are accessed, and forwards the call to the parent
* object store.
*/
+ @Override
public void invalidateObjectsWithGlobalIDs(List anArray) {
// register change so processRecentChanges is called
willChange();
@@ -654,9 +662,9 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
Object o;
EOGlobalID id;
- Iterator it = anArray.iterator();
+ Iterator<EOGlobalID> it = anArray.iterator();
while (it.hasNext()) {
- id = (EOGlobalID) it.next();
+ id = it.next();
if (id != null) {
o = objectForGlobalID(id);
if (o != null) {
@@ -688,6 +696,7 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
* Returns whether the object referenced by the specified id is locked. This
* implementation simply forwards the call to the parent object store.
*/
+ @Override
public boolean isObjectLockedWithGlobalID(EOGlobalID aGlobalID, EOEditingContext aContext) {
return parentStore.isObjectLockedWithGlobalID(aGlobalID, aContext);
}
@@ -709,6 +718,7 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
* context. This implementation simply forwards the call to the parent object
* store.
*/
+ @Override
public void lockObjectWithGlobalID(EOGlobalID aGlobalID, EOEditingContext aContext) {
parentStore.lockObjectWithGlobalID(aGlobalID, aContext);
}
@@ -747,6 +757,7 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
* specified relationship key must produce a result of type Collection for the
* source object or an exception is thrown.
*/
+ @Override
public NSArray objectsForSourceGlobalID(EOGlobalID aGlobalID, String aRelationshipKey, EOEditingContext aContext) {
//System.out.println( "EOEditingContext.objectsForSourceGlobalID: "
//+ aGlobalID + " : " + aRelationshipKey );
@@ -793,7 +804,7 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
} else // not NSArray
if (value instanceof Collection) {
// convert to NSArray
- result = new NSArray((Collection) value);
+ result = new NSArray((Collection<?>) value);
} else {
throw new WotonomyException(
"Relationship key did not return a collection: " + aGlobalID + " : " + aRelationshipKey);
@@ -825,6 +836,7 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
* parent object store, which will register each object in the specified editing
* context only if it does not already exist.
*/
+ @Override
public NSArray objectsWithFetchSpecification(EOFetchSpecification aFetchSpec, EOEditingContext aContext) {
if (aContext == this) {
Object result = notifyDelegate("editingContextShouldFetchObjects",
@@ -869,7 +881,7 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
boolean postStoreInfo = (insertedObjectsBuffer.size() + updatedObjectsBuffer.size() + deletedIDsBuffer.size()
+ invalidatedIDsBuffer.size() > 0);
- NSMutableDictionary storeInfo = new NSMutableDictionary();
+ NSMutableDictionary<String, NSArray> storeInfo = new NSMutableDictionary<>();
if (postStoreInfo) {
storeInfo.setObjectForKey(globalIDsForObjects(insertedObjectsBuffer),
// globalIDsForObjects( insertedObjects ),
@@ -877,10 +889,10 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
storeInfo.setObjectForKey(globalIDsForObjects(updatedObjectsBuffer),
// globalIDsForObjects( updatedObjects ),
EOObjectStore.UpdatedKey);
- storeInfo.setObjectForKey(new NSArray((Collection) deletedIDsBuffer),
+ storeInfo.setObjectForKey(new NSArray((Collection<?>) deletedIDsBuffer),
// globalIDsForObjects( deletedObjects ),
EOObjectStore.DeletedKey);
- storeInfo.setObjectForKey(new NSArray((Collection) invalidatedIDsBuffer), EOObjectStore.InvalidatedKey);
+ storeInfo.setObjectForKey(new NSArray((Collection<?>) invalidatedIDsBuffer), EOObjectStore.InvalidatedKey);
}
// broadcast ObjectsChangedInEditingContextNotification
@@ -889,27 +901,27 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
boolean postContextInfo = (insertedObjectsBuffer.size() + updatedObjectsBuffer.size()
+ deletedObjectsBuffer.size() + invalidatedObjectsBuffer.size() > 0);
- NSMutableDictionary contextInfo = new NSMutableDictionary();
+ NSMutableDictionary<String, NSArray> contextInfo = new NSMutableDictionary<>();
if (postContextInfo) {
- contextInfo.setObjectForKey(new NSArray((Collection) insertedObjectsBuffer),
+ contextInfo.setObjectForKey(new NSArray((Collection<?>) insertedObjectsBuffer),
// new NSArray( (Collection) insertedObjects ),
EOObjectStore.InsertedKey);
- contextInfo.setObjectForKey(new NSArray((Collection) updatedObjectsBuffer),
+ contextInfo.setObjectForKey(new NSArray((Collection<?>) updatedObjectsBuffer),
// new NSArray( (Collection) updatedObjects ),
EOObjectStore.UpdatedKey);
- contextInfo.setObjectForKey(new NSArray((Collection) deletedObjectsBuffer),
+ contextInfo.setObjectForKey(new NSArray((Collection<?>) deletedObjectsBuffer),
// new NSArray( (Collection) deletedObjects ),
EOObjectStore.DeletedKey);
- contextInfo.setObjectForKey(new NSArray((Collection) invalidatedObjectsBuffer),
+ contextInfo.setObjectForKey(new NSArray((Collection<?>) invalidatedObjectsBuffer),
EOObjectStore.InvalidatedKey);
}
// update the current snapshots
Object o;
- Iterator it;
+ Iterator<Object> it;
it = insertedObjectsBuffer.iterator();
while (it.hasNext()) {
o = it.next();
@@ -1024,6 +1036,7 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
* Refaults the specified object, turning it into a fault for the specified
* global id in the specified context.
*/
+ @Override
public void refaultObject(Object anObject, EOGlobalID aGlobalID, EOEditingContext aContext) {
aContext.registrar.setCurrentSnapshot(anObject, null);
@@ -1052,7 +1065,7 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
Object o;
EOGlobalID id;
- Iterator it = registeredObjects().iterator();
+ Iterator<Object> it = registeredObjects().iterator();
while (it.hasNext()) {
o = it.next();
if ((updatedObjects.indexOfIdenticalObject(o) == NSArray.NotFound)
@@ -1088,9 +1101,9 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
return;
Object o;
- Iterator i = editorSet.iterator();
+ Iterator<WeakReference<Editor>> i = editorSet.iterator();
while (i.hasNext()) {
- o = ((WeakReference) i.next()).get();
+ o = i.next().get();
if ((o == null) || (o == anObject)) {
i.remove();
}
@@ -1102,7 +1115,7 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
* timestamp.
*/
public void reset() {
- Iterator it = registeredObjects().iterator();
+ Iterator<Object> it = registeredObjects().iterator();
while (it.hasNext()) {
forgetObject(it.next());
}
@@ -1119,7 +1132,7 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
willChange();
fireWillSaveChanges();
- Iterator it;
+ Iterator<Object> it;
// forget inserted objects
it = new NSArray(insertedObjects).iterator();
@@ -1127,7 +1140,6 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
forgetObject(it.next());
}
- EOGlobalID id;
Object o;
byte[] snapshot;
@@ -1190,10 +1202,10 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
processRecentChanges();
// set up user info for notification to be posted.
- NSMutableDictionary userInfo = new NSMutableDictionary();
- userInfo.setObjectForKey(new NSArray((Collection) insertedObjects), EOObjectStore.InsertedKey);
- userInfo.setObjectForKey(new NSArray((Collection) updatedObjects), EOObjectStore.UpdatedKey);
- userInfo.setObjectForKey(new NSArray((Collection) deletedObjects), EOObjectStore.DeletedKey);
+ NSMutableDictionary<String, NSArray> userInfo = new NSMutableDictionary<>();
+ userInfo.setObjectForKey(new NSArray((Collection<?>) insertedObjects), EOObjectStore.InsertedKey);
+ userInfo.setObjectForKey(new NSArray((Collection<?>) updatedObjects), EOObjectStore.UpdatedKey);
+ userInfo.setObjectForKey(new NSArray((Collection<?>) deletedObjects), EOObjectStore.DeletedKey);
// notify the editors
fireWillSaveChanges();
@@ -1215,8 +1227,8 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
// no exceptions: proceed!
- Object o, key;
- Iterator it;
+ Object o;
+ Iterator<Object> it;
// update the committed snapshots
it = insertedObjects.iterator();
@@ -1249,12 +1261,13 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
* Commits all changes in the specified editing context to this one. Called by
* child editing contexts in their saveChanges() method.
*/
+ @Override
public void saveChangesInEditingContext(EOEditingContext aContext) {
Object o;
- Iterator it;
+ Iterator<Object> it;
// process deletes
- List deletes = new NSArray(aContext.deletedObjects());
+ List<Object> deletes = new NSArray(aContext.deletedObjects());
it = deletes.iterator();
while (it.hasNext()) {
o = it.next();
@@ -1276,7 +1289,7 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
}
// process inserts - all inserts are new objects
- List inserts = new NSArray(aContext.insertedObjects());
+ List<Object> inserts = new NSArray(aContext.insertedObjects());
it = inserts.iterator();
while (it.hasNext()) {
o = it.next();
@@ -1293,7 +1306,7 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
}
// process updates
- List updates = new NSArray(aContext.updatedObjects());
+ List<Object> updates = new NSArray(aContext.updatedObjects());
it = updates.iterator();
while (it.hasNext()) {
willChange(); // need to mark editing context as changed
@@ -1335,7 +1348,7 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
public void setDelegate(Object anObject) {
if (anObject == null)
delegate = null;
- delegate = new WeakReference(anObject);
+ delegate = new WeakReference<>(anObject);
}
/**
@@ -1442,7 +1455,7 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
*/
private void fireWillSaveChanges() {
Object o = null;
- Iterator i = editors().iterator();
+ Iterator<WeakReference<EOEditingContext.Editor>> i = editors().iterator();
while (i.hasNext()) {
try {
o = i.next();
@@ -1477,16 +1490,16 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
NSNotificationCenter.defaultCenter()
.postNotification(new NSNotification(InvalidatedAllObjectsInStoreNotification, this));
} else if (EOGlobalID.GlobalIDChangedNotification.equals(aNotification.name())) {
- NSDictionary userInfo = aNotification.userInfo();
+ NSDictionary<EOGlobalID, ?> userInfo = aNotification.userInfo();
// if any keys in userInfo are registered ids,
// re-register with new permanent values.
Object o;
EOGlobalID id;
- Enumeration e = userInfo.keyEnumerator();
+ Enumeration<EOGlobalID> e = userInfo.keyEnumerator();
while (e.hasMoreElements()) {
- id = (EOGlobalID) e.nextElement();
+ id = e.nextElement();
o = objectForGlobalID(id);
if (o != null) {
// record object is assumed to handle key updates
@@ -1501,16 +1514,16 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
Object o;
EOGlobalID id;
- Enumeration e;
- NSDictionary userInfo = aNotification.userInfo();
+ Enumeration<EOGlobalID> e;
+ NSDictionary<String, NSArray<EOGlobalID>> userInfo = (NSDictionary<String, NSArray<EOGlobalID>>) aNotification.userInfo();
// inserted objects are ignored
// existing deleted objects are removed
- NSArray deletes = (NSArray) userInfo.objectForKey(EOObjectStore.DeletedKey);
+ NSArray<EOGlobalID> deletes = userInfo.objectForKey(EOObjectStore.DeletedKey);
e = deletes.objectEnumerator();
while (e.hasMoreElements()) {
- id = (EOGlobalID) e.nextElement();
+ id = e.nextElement();
o = objectForGlobalID(id);
if (o != null) {
// System.out.println( "EOEditingContext: deleted: " + id );
@@ -1521,10 +1534,10 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
}
// existing updated objects are merged
- NSArray updates = (NSArray) userInfo.objectForKey(EOObjectStore.UpdatedKey);
+ NSArray<EOGlobalID> updates = userInfo.objectForKey(EOObjectStore.UpdatedKey);
e = updates.objectEnumerator();
while (e.hasMoreElements()) {
- id = (EOGlobalID) e.nextElement();
+ id = e.nextElement();
o = objectForGlobalID(id);
if (o != null) {
// System.out.println( "EOEditingContext: updated: " + id );
@@ -1540,10 +1553,10 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
}
// existing invalidated objects are refaulted
- NSArray invalidates = (NSArray) userInfo.objectForKey(EOObjectStore.InvalidatedKey);
+ NSArray<EOGlobalID> invalidates = userInfo.objectForKey(EOObjectStore.InvalidatedKey);
e = invalidates.objectEnumerator();
while (e.hasMoreElements()) {
- id = (EOGlobalID) e.nextElement();
+ id = e.nextElement();
o = objectForGlobalID(id);
if (o != null) {
if (updatedObjects // only invalidate if unchanged
@@ -1719,6 +1732,7 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
* Implementation of the EOObserving interface. Called before objects are
* modified.
*/
+ @Override
public void objectWillChange(Object anObject) {
if (ignoreChanges)
return;
@@ -1812,6 +1826,7 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
* net.wotonomy.util.WotonomyException("Not implemented yet."); }
*/
+ @Override
public String toString() {
return "[EOEditingContext@" + Integer.toHexString(System.identityHashCode(this)) + ":" + " inserted="
+ idsForObjects(insertedObjects) + " updated=" + idsForObjects(updatedObjects) + " deleted="
@@ -2054,6 +2069,7 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
weakComparisonKey = new WeakReferenceKey();
}
+ @Override
public NSArray registeredObjects() {
Object object;
WeakReferenceKey weakKey;
@@ -2072,6 +2088,7 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
return result;
}
+ @Override
public Object objectForGlobalID(EOGlobalID aGlobalID) {
WeakReference ref = (WeakReference) super.objectForGlobalID(aGlobalID);
if (ref == null)
@@ -2089,11 +2106,13 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
return result;
}
+ @Override
public byte[] getCommitSnapshot(Object anObject) {
weakComparisonKey.set(anObject);
return (byte[]) objectsToCommitSnapshots.objectForKey(weakComparisonKey);
}
+ @Override
public void setCommitSnapshot(Object anObject, byte[] aSnapshot) {
if (aSnapshot == null) {
weakComparisonKey.set(anObject);
@@ -2103,11 +2122,13 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
}
}
+ @Override
public byte[] getCurrentSnapshot(Object anObject) {
weakComparisonKey.set(anObject);
return (byte[]) objectsToCurrentSnapshots.objectForKey(weakComparisonKey);
}
+ @Override
public void setCurrentSnapshot(Object anObject, byte[] aSnapshot) {
if (aSnapshot == null) {
weakComparisonKey.set(anObject);
@@ -2117,6 +2138,7 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
}
}
+ @Override
public void registerObject(Object anObject, EOGlobalID aGlobalID) { // new
// net.wotonomy.ui.swing.ReferenceInspector(
// anObject );
@@ -2125,6 +2147,7 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
EOObserverCenter.addObserver(context, anObject);
}
+ @Override
public void forgetObject(Object anObject) {
disposeObject(anObject, null);
}
@@ -2173,6 +2196,7 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
/**
* Returns the actual key's hash code.
*/
+ @Override
public int hashCode() {
return hashCode;
}
@@ -2180,6 +2204,7 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
/**
* Compares by reference.
*/
+ @Override
public boolean equals(Object anObject) {
if (anObject == this)
return true;
@@ -2203,10 +2228,12 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
super(anObject);
}
+ @Override
public Object get() {
return ((WeakReference) referent).get();
}
+ @Override
public void set(Object anObject) {
referent = new WeakReference(anObject);
hashCode = anObject.hashCode();
@@ -2215,6 +2242,7 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
/**
* Compares by reference.
*/
+ @Override
public boolean equals(Object anObject) {
if (anObject == this)
return true;
@@ -2242,10 +2270,12 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
hashCode = object.hashCode() + string.hashCode();
}
+ @Override
public int hashCode() {
return hashCode;
}
+ @Override
public boolean equals(Object anObject) {
if (anObject instanceof CompoundKey) {
CompoundKey key = (CompoundKey) anObject;
@@ -2254,6 +2284,7 @@ public class EOEditingContext extends EOObjectStore implements EOObserving {
return false;
}
+ @Override
public String toString() {
return "[CompoundKey:" + object + ":" + string + "]";
}
diff --git a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EOFaultHandler.java b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EOFaultHandler.java
index e407492..c9c9de4 100644
--- a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EOFaultHandler.java
+++ b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EOFaultHandler.java
@@ -28,7 +28,7 @@ package net.wotonomy.control;
*/
public abstract class EOFaultHandler {
- protected Class _targetClass;
+ protected Class<?> _targetClass;
public EOFaultHandler() {
super();
@@ -61,7 +61,7 @@ public abstract class EOFaultHandler {
((EOFaulting) obj).clearFault();
}
- public Class targetClass() {
+ public Class<?> targetClass() {
return _targetClass;
}
diff --git a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EOKeyValueCodingAdditions.java b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EOKeyValueCodingAdditions.java
index d1bb2c0..f0fdba1 100644
--- a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EOKeyValueCodingAdditions.java
+++ b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EOKeyValueCodingAdditions.java
@@ -47,7 +47,7 @@ public interface EOKeyValueCodingAdditions extends EOKeyValueCoding, NSKeyValueC
* NSKeyValueCodingAdditions, otherwise calls the method on
* DefaultImplementation.
*/
- public static void takeValuesFromDictionary(Object object, Map dictionary) {
+ public static void takeValuesFromDictionary(Object object, Map<String, Object> dictionary) {
if (object instanceof NSKeyValueCodingAdditions) {
((NSKeyValueCodingAdditions) object).takeValuesFromDictionary(dictionary);
} else {
@@ -75,7 +75,7 @@ public interface EOKeyValueCodingAdditions extends EOKeyValueCoding, NSKeyValueC
* NSKeyValueCodingAdditions, otherwise calls the method on
* DefaultImplementation.
*/
- public static NSDictionary valuesForKeys(Object object, List keys) {
+ public static NSDictionary<String, Object> valuesForKeys(Object object, List<String> keys) {
if (object instanceof NSKeyValueCodingAdditions) {
return ((NSKeyValueCodingAdditions) object).valuesForKeys(keys);
} else {
@@ -102,20 +102,20 @@ public interface EOKeyValueCodingAdditions extends EOKeyValueCoding, NSKeyValueC
* NSKeyValueCodingAdditions.
*/
public class DefaultImplementation extends NSKeyValueCodingAdditions.DefaultImplementation {
- public static void takeValuesFromDictionary(Object object, NSDictionary dictionary) {
+ public static void takeValuesFromDictionary(Object object, NSDictionary<String, Object> dictionary) {
throw new RuntimeException("Not implemented yet.");
}
- public static void takeValuesFromDictionaryWithMapping(Object object, NSDictionary dictionary,
- NSDictionary mapping) {
+ public static void takeValuesFromDictionaryWithMapping(Object object, NSDictionary<String, Object> dictionary,
+ NSDictionary<?, ?> mapping) {
throw new RuntimeException("Not implemented yet.");
}
- public static NSDictionary valuesForKeys(Object object, List keys) {
+ public static NSDictionary<String, Object> valuesForKeys(Object object, List<String> keys) {
throw new RuntimeException("Not implemented yet.");
}
- public static NSDictionary valuesForKeysWithMapping(Object object, Map mapping) {
+ public static NSDictionary<String, Object> valuesForKeysWithMapping(Object object, Map<String, Object> mapping) {
throw new RuntimeException("Not implemented yet.");
}
}
diff --git a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EOObjectStore.java b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EOObjectStore.java
index 4f60045..8998bab 100644
--- a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EOObjectStore.java
+++ b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EOObjectStore.java
@@ -103,7 +103,7 @@ public abstract class EOObjectStore {
* must produce a result of type Collection for the source object or an
* exception is thrown.
*/
- public abstract NSArray arrayFaultWithSourceGlobalID(EOGlobalID aGlobalID, String aRelationship,
+ public abstract NSArray<?> arrayFaultWithSourceGlobalID(EOGlobalID aGlobalID, String aRelationship,
EOEditingContext aContext);
/**
@@ -187,7 +187,7 @@ public abstract class EOObjectStore {
public abstract void refaultObject(Object anObject, EOGlobalID aGlobalID, EOEditingContext aContext);
/**
- * Writes all changes in the specified editing context to the respository. The
+ * Writes all changes in the specified editing context to the repository. The
* object store is expected to post a notification that should be named with the
* string constant ObjectsChangedInStoreNotification with this object store as
* the object and user info containing keys named UpdatedKey, InsertedKey, and
diff --git a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EOObjectStoreCoordinator.java b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EOObjectStoreCoordinator.java
index c2ad03d..6fa0486 100644
--- a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EOObjectStoreCoordinator.java
+++ b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EOObjectStoreCoordinator.java
@@ -20,7 +20,7 @@ $Id: EOObjectStoreCoordinator.java 894 2006-02-16 16:47:14Z cgruber $
*/
package net.wotonomy.control;
-
+
import java.util.List;
import java.util.Map;
diff --git a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EOTemporaryGlobalID.java b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EOTemporaryGlobalID.java
index 31351a9..b5c60b7 100644
--- a/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EOTemporaryGlobalID.java
+++ b/projects/net.wotonomy.persistence/src/main/java/net/wotonomy/control/EOTemporaryGlobalID.java
@@ -37,6 +37,8 @@ import java.net.InetAddress;
* @version $Revision: 893 $
*/
public class EOTemporaryGlobalID extends EOGlobalID {
+ private static final long serialVersionUID = 7652533198394290800L;
+
/**
* Holds the length in bytes of the key that is generated.
*/