You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by ju...@apache.org on 2013/04/16 21:07:29 UTC

svn commit: r1468561 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory: MemoryNodeBuilder.java ModifiedNodeState.java

Author: jukka
Date: Tue Apr 16 19:07:29 2013
New Revision: 1468561

URL: http://svn.apache.org/r1468561
Log:
OAK-778: Recursive wrapping of ModifiedNodeState

Simplify code by removing unused bits and reducing method visibility

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilder.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/ModifiedNodeState.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilder.java?rev=1468561&r1=1468560&r2=1468561&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilder.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilder.java Tue Apr 16 19:07:29 2013
@@ -31,9 +31,10 @@ import org.apache.jackrabbit.oak.spi.sta
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.state.NodeStateDiff;
 
-import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkNotNull;
 import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.collect.Lists.newArrayList;
+import static com.google.common.collect.Maps.newHashMap;
 import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE;
 import static org.apache.jackrabbit.oak.plugins.memory.ModifiedNodeState.with;
 import static org.apache.jackrabbit.oak.plugins.memory.ModifiedNodeState.withNodes;
@@ -291,13 +292,6 @@ public class MemoryNodeBuilder implement
         // do nothing
     }
 
-    protected void compareAgainstBaseState(NodeStateDiff diff) {
-        NodeState state = read();
-        if (writeState != null) {
-            writeState.compareAgainstBaseState(state, diff);
-        }
-    }
-
     //--------------------------------------------------------< NodeBuilder >---
 
     @Override
@@ -496,15 +490,13 @@ public class MemoryNodeBuilder implement
          * Set of added, modified or removed ({@code null} value)
          * property states.
          */
-        private final Map<String, PropertyState> properties =
-                Maps.newHashMap();
+        private final Map<String, PropertyState> properties = newHashMap();
 
         /**
          * Set of added, modified or removed ({@code null} value)
          * child nodes.
          */
-        private final Map<String, MutableNodeState> nodes =
-                Maps.newHashMap();
+        private final Map<String, MutableNodeState> nodes = newHashMap();
 
         public MutableNodeState(NodeState base) {
             if (base != null) {
@@ -576,7 +568,7 @@ public class MemoryNodeBuilder implement
 
         @Override @Nonnull
         public Iterable<? extends PropertyState> getProperties() {
-            Map<String, PropertyState> copy = Maps.newHashMap(properties);
+            Map<String, PropertyState> copy = newHashMap(properties);
             return withProperties(base, copy).getProperties();
         }
 
@@ -594,26 +586,23 @@ public class MemoryNodeBuilder implement
 
         @Override
         public NodeState getChildNode(String name) {
-            checkNotNull(name);
-            checkArgument(!name.isEmpty());
-            return withNodes(base, nodes).getChildNode(name); // mutable
+            throw new UnsupportedOperationException();
         }
 
         @Override @Nonnull
         public Iterable<String> getChildNodeNames() {
             Map<String, MutableNodeState> copy = Maps.newHashMap(nodes);
-            return withNodes(base, copy).getChildNodeNames();
+            return newArrayList(withNodes(base, copy).getChildNodeNames());
         }
 
         @Override @Nonnull
         public Iterable<? extends ChildNodeEntry> getChildNodeEntries() {
-            Map<String, MutableNodeState> copy = Maps.newHashMap(nodes);
-            return withNodes(base, copy).getChildNodeEntries();
+            throw new UnsupportedOperationException();
         }
 
         @Override
         public void compareAgainstBaseState(NodeState base, NodeStateDiff diff) {
-            with(this.base, properties, nodes).compareAgainstBaseState(base, diff);
+            throw new UnsupportedOperationException();
         }
 
         @Override @Nonnull

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/ModifiedNodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/ModifiedNodeState.java?rev=1468561&r1=1468560&r2=1468561&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/ModifiedNodeState.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/ModifiedNodeState.java Tue Apr 16 19:07:29 2013
@@ -48,7 +48,7 @@ import com.google.common.collect.Maps;
  */
 public class ModifiedNodeState extends AbstractNodeState {
 
-    public static NodeState withProperties(
+    static NodeState withProperties(
             NodeState base, Map<String, ? extends PropertyState> properties) {
         if (properties.isEmpty()) {
             return base;
@@ -57,7 +57,7 @@ public class ModifiedNodeState extends A
         }
     }
 
-    public static NodeState withNodes(
+    static NodeState withNodes(
             NodeState base, Map<String, ? extends NodeState> nodes) {
         if (nodes.isEmpty()) {
             return base;
@@ -66,7 +66,7 @@ public class ModifiedNodeState extends A
         }
     }
 
-    public static NodeState with(
+    static NodeState with(
             NodeState base,
             Map<String, ? extends PropertyState> properties,
             Map<String, ? extends NodeState> nodes) {
@@ -111,7 +111,7 @@ public class ModifiedNodeState extends A
      */
     private final Map<String, ? extends NodeState> nodes;
 
-    public ModifiedNodeState(
+    private ModifiedNodeState(
             @Nonnull NodeState base,
             @Nonnull Map<String, ? extends PropertyState> properties,
             @Nonnull Map<String, ? extends NodeState> nodes) {