cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From and...@apache.org
Subject svn commit: r765237 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne: access/ToManyList.java util/PersistentObjectList.java
Date Wed, 15 Apr 2009 15:24:15 GMT
Author: andrey
Date: Wed Apr 15 15:24:15 2009
New Revision: 765237

URL: http://svn.apache.org/viewvc?rev=765237&view=rev
Log:
futher ToManyList & PersistentObjectList refactring

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ToManyList.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/util/PersistentObjectList.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ToManyList.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ToManyList.java?rev=765237&r1=765236&r2=765237&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ToManyList.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ToManyList.java
Wed Apr 15 15:24:15 2009
@@ -73,34 +73,18 @@
     // Tracking list modifications, and resolving it
     // on demand
     // ====================================================
-
+    
     @Override
-    protected boolean removeLocal(Object object) {
-        if (addedToUnresolved != null) {
-            addedToUnresolved.remove(object);
-        }
-
-        if (removedFromUnresolved == null) {
-            removedFromUnresolved = new LinkedList<Object>();
-        }
-
+    protected boolean shouldAddToRemovedFromUnresolvedList(Object object) {
         // No point in adding a new or transient object -- these will never be fetched
         // from the database.
-        boolean shouldAddToRemovedFromUnresolvedList = true;
         if (object instanceof Persistent) {
             Persistent dataObject = (Persistent) object;
             if ((dataObject.getPersistenceState() == PersistenceState.TRANSIENT)
                     || (dataObject.getPersistenceState() == PersistenceState.NEW)) {
-                shouldAddToRemovedFromUnresolvedList = false;
+                return false;
             }
         }
-
-        if (shouldAddToRemovedFromUnresolvedList) {
-            removedFromUnresolved.addLast(object);
-        }
-
-        // this is really meaningless, since we don't know
-        // if an object was present in the list
         return true;
     }
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/util/PersistentObjectList.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/util/PersistentObjectList.java?rev=765237&r1=765236&r2=765237&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/util/PersistentObjectList.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/util/PersistentObjectList.java
Wed Apr 15 15:24:15 2009
@@ -375,12 +375,21 @@
             removedFromUnresolved = new LinkedList<Object>();
         }
 
-        removedFromUnresolved.addLast(object);
+        if (shouldAddToRemovedFromUnresolvedList(object)) {
+            removedFromUnresolved.addLast(object);
+        }
 
         // this is really meaningless, since we don't know
         // if an object was present in the list
         return true;
     }
+    
+    /**
+     * @return whether object should be added to {@link #removedFromUnresolved} during removal
+     */
+    protected boolean shouldAddToRemovedFromUnresolvedList(Object object) {
+        return true;
+    }
 
     protected void postprocessAdd(Collection collection) {
         Iterator it = collection.iterator();



Mime
View raw message