You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2013/08/04 11:51:55 UTC

svn commit: r1510121 - in /cayenne/main/trunk/framework/cayenne-core-unpublished/src: main/java/org/apache/cayenne/access/ main/java/org/apache/cayenne/graph/ test/java/org/apache/cayenne/access/

Author: aadamchik
Date: Sun Aug  4 09:51:54 2013
New Revision: 1510121

URL: http://svn.apache.org/r1510121
Log:
cleanup

Modified:
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/ObjectDiff.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/ObjectStoreGraphDiff.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/graph/CompoundDiff.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/access/DeleteRulesTest.java

Modified: cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/ObjectDiff.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/ObjectDiff.java?rev=1510121&r1=1510120&r2=1510121&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/ObjectDiff.java (original)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/ObjectDiff.java Sun Aug  4 09:51:54 2013
@@ -53,7 +53,7 @@ class ObjectDiff extends NodeDiff {
 
     private transient ClassDescriptor classDescriptor;
 
-    private Collection<GraphDiff> otherDiffs;
+    private Collection<NodeDiff> otherDiffs;
 
     private Map<String, Object> snapshot;
     private Map<String, Object> arcSnapshot;
@@ -92,15 +92,18 @@ class ObjectDiff extends NodeDiff {
 
             classDescriptor.visitProperties(new PropertyVisitor() {
 
+                @Override
                 public boolean visitAttribute(AttributeProperty property) {
                     snapshot.put(property.getName(), property.readProperty(object));
                     return true;
                 }
 
+                @Override
                 public boolean visitToMany(ToManyProperty property) {
                     return true;
                 }
 
+                @Override
                 public boolean visitToOne(ToOneProperty property) {
 
                     // eagerly resolve optimistically locked relationships
@@ -157,7 +160,7 @@ class ObjectDiff extends NodeDiff {
     /**
      * Appends individual diffs to collection.
      */
-    void appendDiffs(Collection collection) {
+    void appendDiffs(Collection<NodeDiff> collection) {
 
         if (otherDiffs != null) {
             collection.addAll(otherDiffs);
@@ -177,7 +180,7 @@ class ObjectDiff extends NodeDiff {
         });
     }
 
-    void addDiff(GraphDiff diff) {
+    void addDiff(NodeDiff diff) {
 
         boolean addDiff = true;
 
@@ -233,7 +236,7 @@ class ObjectDiff extends NodeDiff {
 
         if (addDiff) {
             if (otherDiffs == null) {
-                otherDiffs = new ArrayList<GraphDiff>(3);
+                otherDiffs = new ArrayList<NodeDiff>(3);
             }
 
             otherDiffs.add(diff);
@@ -266,6 +269,7 @@ class ObjectDiff extends NodeDiff {
 
         getClassDescriptor().visitProperties(new PropertyVisitor() {
 
+            @Override
             public boolean visitAttribute(AttributeProperty property) {
 
                 Object oldValue = snapshot.get(property.getName());
@@ -278,11 +282,13 @@ class ObjectDiff extends NodeDiff {
                 return !modFound[0];
             }
 
+            @Override
             public boolean visitToMany(ToManyProperty property) {
                 // flattened changes
                 return true;
             }
 
+            @Override
             public boolean visitToOne(ToOneProperty property) {
                 if (arcSnapshot == null) {
                     return true;
@@ -326,6 +332,7 @@ class ObjectDiff extends NodeDiff {
 
         getClassDescriptor().visitProperties(new PropertyVisitor() {
 
+            @Override
             public boolean visitAttribute(AttributeProperty property) {
 
                 Object newValue = property.readProperty(object);
@@ -349,10 +356,12 @@ class ObjectDiff extends NodeDiff {
                 return true;
             }
 
+            @Override
             public boolean visitToMany(ToManyProperty property) {
                 return true;
             }
 
+            @Override
             public boolean visitToOne(ToOneProperty property) {
                 return true;
             }

Modified: cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/ObjectStoreGraphDiff.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/ObjectStoreGraphDiff.java?rev=1510121&r1=1510120&r2=1510121&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/ObjectStoreGraphDiff.java (original)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/ObjectStoreGraphDiff.java Sun Aug  4 09:51:54 2013
@@ -25,6 +25,7 @@ import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 
 import org.apache.cayenne.ObjectId;
 import org.apache.cayenne.PersistenceState;
@@ -33,12 +34,14 @@ import org.apache.cayenne.Validating;
 import org.apache.cayenne.graph.CompoundDiff;
 import org.apache.cayenne.graph.GraphChangeHandler;
 import org.apache.cayenne.graph.GraphDiff;
+import org.apache.cayenne.graph.NodeDiff;
 import org.apache.cayenne.validation.ValidationException;
 import org.apache.cayenne.validation.ValidationResult;
 
 /**
- * A GraphDiff facade for the ObjectStore changes. Provides a way for the lower layers of
- * the access stack to speed up processing of presorted ObjectStore diffs.
+ * A GraphDiff facade for the ObjectStore changes. Provides a way for the lower
+ * layers of the access stack to speed up processing of presorted ObjectStore
+ * diffs.
  * 
  * @since 1.2
  */
@@ -66,7 +69,8 @@ class ObjectStoreGraphDiff implements Gr
 
         boolean noop = true;
 
-        // build a new collection for validation as validation methods may result in
+        // build a new collection for validation as validation methods may
+        // result in
         // ObjectStore modifications
 
         Collection objectsToValidate = null;
@@ -95,15 +99,15 @@ class ObjectStoreGraphDiff implements Gr
             while (validationIt.hasNext()) {
                 Validating object = (Validating) validationIt.next();
                 switch (((Persistent) object).getPersistenceState()) {
-                    case PersistenceState.NEW:
-                        object.validateForInsert(result);
-                        break;
-                    case PersistenceState.MODIFIED:
-                        object.validateForUpdate(result);
-                        break;
-                    case PersistenceState.DELETED:
-                        object.validateForDelete(result);
-                        break;
+                case PersistenceState.NEW:
+                    object.validateForInsert(result);
+                    break;
+                case PersistenceState.MODIFIED:
+                    object.validateForUpdate(result);
+                    break;
+                case PersistenceState.DELETED:
+                    object.validateForDelete(result);
+                    break;
                 }
             }
 
@@ -140,8 +144,8 @@ class ObjectStoreGraphDiff implements Gr
     }
 
     /**
-     * Converts diffs organized by ObjectId in a collection of diffs sorted by diffId
-     * (same as creation order).
+     * Converts diffs organized by ObjectId in a collection of diffs sorted by
+     * diffId (same as creation order).
      */
     private void resolveDiff() {
         if (resolvedDiff == null) {
@@ -150,7 +154,7 @@ class ObjectStoreGraphDiff implements Gr
             Map<Object, ObjectDiff> changes = getChangesByObjectId();
 
             if (!changes.isEmpty()) {
-                List allChanges = new ArrayList(changes.size() * 2);
+                List<NodeDiff> allChanges = new ArrayList<NodeDiff>(changes.size() * 2);
 
                 for (final ObjectDiff objectDiff : changes.values()) {
                     objectDiff.appendDiffs(allChanges);
@@ -166,12 +170,10 @@ class ObjectStoreGraphDiff implements Gr
 
     private void preprocess(ObjectStore objectStore) {
 
-        Map changes = getChangesByObjectId();
+        Map<Object, ObjectDiff> changes = getChangesByObjectId();
         if (!changes.isEmpty()) {
 
-            Iterator it = changes.entrySet().iterator();
-            while (it.hasNext()) {
-                Map.Entry entry = (Map.Entry) it.next();
+            for (Entry<Object, ObjectDiff> entry : changes.entrySet()) {
 
                 ObjectId id = (ObjectId) entry.getKey();
 

Modified: cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/graph/CompoundDiff.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/graph/CompoundDiff.java?rev=1510121&r1=1510120&r2=1510121&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/graph/CompoundDiff.java (original)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/graph/CompoundDiff.java Sun Aug  4 09:51:54 2013
@@ -74,7 +74,7 @@ public class CompoundDiff implements Gra
         nonNullDiffs().add(diff);
     }
 
-    public void addAll(Collection<GraphDiff> diffs) {
+    public void addAll(Collection<? extends GraphDiff> diffs) {
         nonNullDiffs().addAll(diffs);
     }
 

Modified: cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/access/DeleteRulesTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/access/DeleteRulesTest.java?rev=1510121&r1=1510120&r2=1510121&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/access/DeleteRulesTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/access/DeleteRulesTest.java Sun Aug  4 09:51:54 2013
@@ -27,6 +27,7 @@ import org.apache.cayenne.DeleteDenyExce
 import org.apache.cayenne.PersistenceState;
 import org.apache.cayenne.access.ObjectDiff.ArcOperation;
 import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.graph.NodeDiff;
 import org.apache.cayenne.map.DeleteRule;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.ObjRelationship;
@@ -332,7 +333,7 @@ public class DeleteRulesTest extends Ser
         ObjectDiff changes = context.getObjectStore().changes.get(a.getObjectId());
 
         assertNotNull(changes);
-        Collection<?> diffs = new ArrayList<Object>();
+        Collection<NodeDiff> diffs = new ArrayList<NodeDiff>();
         changes.appendDiffs(diffs);
         Iterator<?> it = diffs.iterator();
         while (it.hasNext()) {
@@ -354,7 +355,7 @@ public class DeleteRulesTest extends Ser
         ObjectDiff changes = context.getObjectStore().changes.get(a.getObjectId());
 
         if (changes != null) {
-            Collection<?> diffs = new ArrayList<Object>();
+            Collection<NodeDiff> diffs = new ArrayList<NodeDiff>();
             changes.appendDiffs(diffs);
             Iterator<?> it = diffs.iterator();
             while (it.hasNext()) {