jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1342190 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak: plugins/memory/MemoryChildNodeEntry.java plugins/memory/ModifiedNodeState.java spi/state/ChildNodeEntry.java
Date Thu, 24 May 2012 10:35:53 GMT
Author: mduerig
Date: Thu May 24 10:35:52 2012
New Revision: 1342190

URL: http://svn.apache.org/viewvc?rev=1342190&view=rev
Log:
OAK-37: Use nullability annotation to enforce/document API contract
- add nullability annotations to ChildNodeEntry

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryChildNodeEntry.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/ModifiedNodeState.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/ChildNodeEntry.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryChildNodeEntry.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryChildNodeEntry.java?rev=1342190&r1=1342189&r2=1342190&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryChildNodeEntry.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryChildNodeEntry.java
Thu May 24 10:35:52 2012
@@ -18,13 +18,14 @@
  */
 package org.apache.jackrabbit.oak.plugins.memory;
 
-import java.util.Iterator;
-import java.util.Map;
-
 import org.apache.jackrabbit.oak.spi.state.AbstractChildNodeEntry;
 import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+
 /**
  * Basic JavaBean implementation of a child node entry.
  */
@@ -60,6 +61,27 @@ public class MemoryChildNodeEntry extend
         };
     }
 
+    public static Iterator<ChildNodeEntry> iterator(
+            final Iterator<Entry<String, NodeState>> iterator) {
+
+        return new Iterator<ChildNodeEntry>() {
+            @Override
+            public boolean hasNext() {
+                return iterator.hasNext();
+            }
+
+            @Override
+            public ChildNodeEntry next() {
+                return new MemoryChildNodeEntry(iterator.next());
+            }
+
+            @Override
+            public void remove() {
+                throw new UnsupportedOperationException();
+            }
+        };
+    }
+
     private final String name;
 
     private final NodeState node;
@@ -72,6 +94,13 @@ public class MemoryChildNodeEntry extend
      * @param node child node state
      */
     public MemoryChildNodeEntry(String name, NodeState node) {
+        if (name == null) {
+            throw new IllegalArgumentException("Name must not be null");
+        }
+        if (node == null) {
+            throw new IllegalArgumentException("Node must not be null");
+        }
+
         this.name = name;
         this.node = node;
     }

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=1342190&r1=1342189&r2=1342190&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
Thu May 24 10:35:52 2012
@@ -27,6 +27,7 @@ import org.apache.jackrabbit.oak.spi.sta
 
 import java.util.Iterator;
 import java.util.Map;
+import java.util.Map.Entry;
 
 public class ModifiedNodeState extends AbstractNodeState {
 
@@ -162,18 +163,17 @@ public class ModifiedNodeState extends A
         }
         final Iterable<? extends ChildNodeEntry> unmodified =
                 base.getChildNodeEntries();
-        final Iterable<? extends ChildNodeEntry> modified =
-                MemoryChildNodeEntry.iterable(nodes);
+        final Iterator<Entry<String, NodeState>> modified = nodes.entrySet().iterator();
         return new Iterable<ChildNodeEntry>() {
             @Override @SuppressWarnings("unchecked")
             public Iterator<ChildNodeEntry> iterator() {
                 Iterator<ChildNodeEntry> a = IteratorUtils.filteredIterator(
                         unmodified.iterator(),
                         new UnmodifiedChildNodePredicate());
-                Iterator<ChildNodeEntry> b = IteratorUtils.filteredIterator(
-                        modified.iterator(),
+                Iterator<Entry<String, NodeState>> b = IteratorUtils.filteredIterator(
+                        modified,
                         new UndeletedChildNodePredicate());
-                return IteratorUtils.chainedIterator(a, b);
+                return IteratorUtils.chainedIterator(a, MemoryChildNodeEntry.iterator(b));
             }
         };
     }
@@ -210,9 +210,9 @@ public class ModifiedNodeState extends A
 
         @Override
         public boolean evaluate(Object object) {
-            if (object instanceof ChildNodeEntry) {
-                ChildNodeEntry entry = ((ChildNodeEntry) object);
-                return entry.getNodeState() != null;
+            if (object instanceof Entry) {
+                Entry<?, ?> entry = ((Entry<?, ?>) object);
+                return entry.getValue() != null;
             } else {
                 return false;
             }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/ChildNodeEntry.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/ChildNodeEntry.java?rev=1342190&r1=1342189&r2=1342190&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/ChildNodeEntry.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/ChildNodeEntry.java
Thu May 24 10:35:52 2012
@@ -17,6 +17,8 @@
 package org.apache.jackrabbit.oak.spi.state;
 
 
+import javax.annotation.Nonnull;
+
 /**
  * TODO: document OR replace by mk.model ChildNodeEntry interface
  *
@@ -34,11 +36,13 @@ public interface ChildNodeEntry {
     /**
      * TODO: document
      */
+    @Nonnull
     String getName();
 
     /**
      * TODO: document
      */
+    @Nonnull
     NodeState getNodeState();
 
 }



Mime
View raw message