jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1502474 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/core/ test/java/org/apache/jackrabbit/oak/core/
Date Fri, 12 Jul 2013 08:43:46 GMT
Author: mduerig
Date: Fri Jul 12 08:43:45 2013
New Revision: 1502474

URL: http://svn.apache.org/r1502474
Log:
OAK-798: Review / refactor TreeImpl and related classes
Rename TreeImpl to MutableTree to better reflect its purpose and align with naming of ImmutableTree

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableTree.java
  (contents, props changed)
      - copied, changed from r1502473, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/MutableTreeTest.java
  (contents, props changed)
      - copied, changed from r1502473, jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/TreeImplTest.java
Removed:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/TreeImplTest.java
Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ImmutableTree.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/ImmutableTreeTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ImmutableTree.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ImmutableTree.java?rev=1502474&r1=1502473&r2=1502474&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ImmutableTree.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ImmutableTree.java
Fri Jul 12 08:43:45 2013
@@ -82,7 +82,7 @@ import org.apache.jackrabbit.oak.spi.sta
  * </ul>
  *
  * <h3>Equality and hash code</h3>
- * In contrast to {@link TreeImpl} the {@code ImmutableTree} implements
+ * In contrast to {@link MutableTree} the {@code ImmutableTree} implements
  * {@link Object#equals(Object)} and {@link Object#hashCode()}: Two {@code ImmutableTree}s
  * are consider equal if their name and the underlying {@code NodeState}s are equal. Note
  * however, that according to the contract defined in {@code NodeState} these

Copied: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableTree.java
(from r1502473, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableTree.java?p2=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableTree.java&p1=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java&r1=1502473&r2=1502474&rev=1502474&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableTree.java
Fri Jul 12 08:43:45 2013
@@ -50,7 +50,7 @@ import org.apache.jackrabbit.oak.spi.sta
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.state.PropertyBuilder;
 
-public class TreeImpl extends AbstractTree {
+public class MutableTree extends AbstractTree {
 
     /**
      * Underlying {@code Root} of this {@code Tree} instance
@@ -60,18 +60,18 @@ public class TreeImpl extends AbstractTr
     /**
      * Parent of this tree. Null for the root.
      */
-    private TreeImpl parent;
+    private MutableTree parent;
 
     /** Pointer into the list of pending moves */
     private Move pendingMoves;
 
-    TreeImpl(RootImpl root, NodeBuilder builder, Move pendingMoves) {
+    MutableTree(RootImpl root, NodeBuilder builder, Move pendingMoves) {
         super("", builder, false);
         this.root = checkNotNull(root);
         this.pendingMoves = checkNotNull(pendingMoves);
     }
 
-    private TreeImpl(RootImpl root, TreeImpl parent, String name, Move pendingMoves) {
+    private MutableTree(RootImpl root, MutableTree parent, String name, Move pendingMoves)
{
         super(name, parent.nodeBuilder.getChildNode(name), false);
         this.root = checkNotNull(root);
         this.parent = checkNotNull(parent);
@@ -79,8 +79,8 @@ public class TreeImpl extends AbstractTr
     }
 
     @Override
-    protected TreeImpl createChild(String name) {
-        return new TreeImpl(root, this, name, pendingMoves);
+    protected MutableTree createChild(String name) {
+        return new MutableTree(root, this, name, pendingMoves);
     }
 
     //------------------------------------------------------------< Tree >---
@@ -109,7 +109,7 @@ public class TreeImpl extends AbstractTr
     }
 
     @Override
-    public TreeImpl getParent() {
+    public MutableTree getParent() {
         checkState(parent != null, "root tree does not have a parent");
         root.checkLive();
         return parent;
@@ -251,7 +251,7 @@ public class TreeImpl extends AbstractTr
                 new Predicate<String>() {
                     @Override
                     public boolean apply(String name) {
-                        return !TreeImpl.this.name.equals(name);
+                        return !MutableTree.this.name.equals(name);
                     }
                 });
         // create head and tail
@@ -320,7 +320,7 @@ public class TreeImpl extends AbstractTr
      * @param destParent new parent for this tree
      * @param destName   new name for this tree
      */
-    void moveTo(TreeImpl destParent, String destName) {
+    void moveTo(MutableTree destParent, String destName) {
         name = destName;
         parent = destParent;
     }
@@ -331,11 +331,11 @@ public class TreeImpl extends AbstractTr
      * @return a {@link Tree} instance for the child at {@code path}.
      */
     @CheckForNull
-    TreeImpl getTree(@Nonnull String path) {
+    MutableTree getTree(@Nonnull String path) {
         checkArgument(isAbsolute(checkNotNull(path)));
-        TreeImpl child = this;
+        MutableTree child = this;
         for (String name : elements(path)) {
-            child = new TreeImpl(root, child, name, pendingMoves);
+            child = new MutableTree(root, child, name, pendingMoves);
         }
         return child;
     }

Propchange: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableTree.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableTree.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java?rev=1502474&r1=1502473&r2=1502474&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
Fri Jul 12 08:43:45 2013
@@ -92,7 +92,7 @@ public class RootImpl implements Root {
     /**
      * Current root {@code Tree}
      */
-    private final TreeImpl rootTree;
+    private final MutableTree rootTree;
 
     /**
      * Current branch this root operates on
@@ -144,7 +144,7 @@ public class RootImpl implements Root {
         NodeState root = branch.getHead();
         builder = root.builder();
         NodeBuilder secureBuilder = new SecureNodeBuilder(builder, getRootContext(root));
-        rootTree = new TreeImpl(this, secureBuilder, lastMove);
+        rootTree = new MutableTree(this, secureBuilder, lastMove);
     }
 
     // TODO: review if these constructors really make sense and cannot be replaced.
@@ -183,7 +183,7 @@ public class RootImpl implements Root {
         }
 
         checkLive();
-        TreeImpl destParent = rootTree.getTree(getParentPath(destPath));
+        MutableTree destParent = rootTree.getTree(getParentPath(destPath));
         if (!destParent.exists()) {
             return false;
         }
@@ -211,7 +211,7 @@ public class RootImpl implements Root {
     }
 
     @Override
-    public TreeImpl getTree(@Nonnull String path) {
+    public MutableTree getTree(@Nonnull String path) {
         checkLive();
         return rootTree.getTree(path);
     }
@@ -458,7 +458,7 @@ public class RootImpl implements Root {
      * {@code setMove()}. This fills the slot with the source and destination of the move
      * and links this move to the next one which will be the new empty slot.
      *
-     * Moves can be applied to {@code TreeImpl} instances by calling {@code apply()},
+     * Moves can be applied to {@code MutableTree} instances by calling {@code apply()},
      * which will execute all moves in the list on the passed tree instance
      */
     class Move {
@@ -467,7 +467,7 @@ public class RootImpl implements Root {
         private String source;
 
         /** Parent tree of the destination */
-        private TreeImpl destParent;
+        private MutableTree destParent;
 
         /** Name at the destination */
         private String destName;
@@ -479,7 +479,7 @@ public class RootImpl implements Root {
          * Set this move to the given source and destination. Creates a new empty slot,
          * sets this as the next move and returns it.
          */
-        Move setMove(String source, TreeImpl destParent, String destName) {
+        Move setMove(String source, MutableTree destParent, String destName) {
             this.source = source;
             this.destParent = destParent;
             this.destName = destName;
@@ -489,7 +489,7 @@ public class RootImpl implements Root {
         /**
          * Apply this and all subsequent moves to the passed tree instance.
          */
-        Move apply(TreeImpl tree) {
+        Move apply(MutableTree tree) {
             Move move = this;
             while (move.next != null) {
                 if (move.source.equals(tree.getPathInternal())) {

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/ImmutableTreeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/ImmutableTreeTest.java?rev=1502474&r1=1502473&r2=1502474&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/ImmutableTreeTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/ImmutableTreeTest.java
Fri Jul 12 08:43:45 2013
@@ -60,7 +60,7 @@ public class ImmutableTreeTest extends O
 
     @Test
     public void testGetPath() {
-        TreeImpl tree = (TreeImpl) root.getTree("/");
+        MutableTree tree = (MutableTree) root.getTree("/");
 
         ImmutableTree immutable = new ImmutableTree(tree.getNodeState());
         assertEquals("/", immutable.getPath());
@@ -122,7 +122,7 @@ public class ImmutableTreeTest extends O
     
     @Test
     public void orderBefore() throws Exception {
-    	 TreeImpl t = (TreeImpl) root.getTree("/x/y/z");
+    	 MutableTree t = (MutableTree) root.getTree("/x/y/z");
    
          t.addChild("node1");
          t.addChild("node2");

Copied: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/MutableTreeTest.java
(from r1502473, jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/TreeImplTest.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/MutableTreeTest.java?p2=jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/MutableTreeTest.java&p1=jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/TreeImplTest.java&r1=1502473&r2=1502474&rev=1502474&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/TreeImplTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/MutableTreeTest.java
Fri Jul 12 08:43:45 2013
@@ -42,9 +42,9 @@ import org.junit.Before;
 import org.junit.Test;
 
 /**
- * TreeImplTest...
+ * MutableTreeTest...
  */
-public class TreeImplTest extends OakBaseTest {
+public class MutableTreeTest extends OakBaseTest {
 
     private Root root;
 
@@ -363,20 +363,20 @@ public class TreeImplTest extends OakBas
     public void testSetOrderableChildrenSetsProperty() throws Exception {
         Tree tree = root.getTree("/").addChild("test");
         tree.setOrderableChildren(true);
-        assertTrue(((TreeImpl) tree).getNodeState().hasProperty(AbstractTree.OAK_CHILD_ORDER));
+        assertTrue(((MutableTree) tree).getNodeState().hasProperty(AbstractTree.OAK_CHILD_ORDER));
 
         tree.setOrderableChildren(false);
-        assertFalse(((TreeImpl) tree).getNodeState().hasProperty(AbstractTree.OAK_CHILD_ORDER));
+        assertFalse(((MutableTree) tree).getNodeState().hasProperty(AbstractTree.OAK_CHILD_ORDER));
 
         tree.setOrderableChildren(true);
         root.commit();
 
-        assertTrue(((TreeImpl) tree).getNodeState().hasProperty(AbstractTree.OAK_CHILD_ORDER));
+        assertTrue(((MutableTree) tree).getNodeState().hasProperty(AbstractTree.OAK_CHILD_ORDER));
 
         tree.setOrderableChildren(false);
         root.commit();
 
-        assertFalse(((TreeImpl) tree).getNodeState().hasProperty(AbstractTree.OAK_CHILD_ORDER));
+        assertFalse(((MutableTree) tree).getNodeState().hasProperty(AbstractTree.OAK_CHILD_ORDER));
     }
 
     @Test

Propchange: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/MutableTreeTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/MutableTreeTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL



Mime
View raw message