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 re...@apache.org on 2012/05/21 16:34:53 UTC

svn commit: r1341047 - in /jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr: NodeDelegate.java NodeImpl.java

Author: reschke
Date: Mon May 21 14:34:52 2012
New Revision: 1341047

URL: http://svn.apache.org/viewvc?rev=1341047&view=rev
Log:
OAK-37: Use nullability annotation to enforce/document API contract (WIP)

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java?rev=1341047&r1=1341046&r2=1341047&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java Mon May 21 14:34:52 2012
@@ -28,6 +28,7 @@ import java.util.Iterator;
 import java.util.List;
 
 import javax.annotation.CheckForNull;
+import javax.annotation.Nonnull;
 
 /**
  * {@code NodeDelegate} serve as internal representations of {@code Node}s.
@@ -157,6 +158,7 @@ public class NodeDelegate extends ItemDe
      * @return  node at the path given by {@code relPath} or {@code null} if
      * no such node exists
      */
+    @CheckForNull
     public NodeDelegate getChild(String relPath) {
         Tree tree = getTree(relPath);
         return tree == null ? null : new NodeDelegate(sessionDelegate, tree);
@@ -176,6 +178,7 @@ public class NodeDelegate extends ItemDe
      * @param value
      * @return  the set property
      */
+    @Nonnull
     public PropertyDelegate setProperty(String name, CoreValue value) {
         PropertyState propertyState = getTree().setProperty(name, value);
         return new PropertyDelegate(sessionDelegate, getTree(), propertyState);
@@ -187,6 +190,7 @@ public class NodeDelegate extends ItemDe
      * @param value
      * @return  the set property
      */
+    @Nonnull
     public PropertyDelegate setProperty(String name, List<CoreValue> value) {
         PropertyState propertyState = getTree().setProperty(name, value);
         return new PropertyDelegate(sessionDelegate, getTree(), propertyState);
@@ -197,6 +201,7 @@ public class NodeDelegate extends ItemDe
      * @param name  oak name
      * @return  the added node or {@code null} if such a node already exists
      */
+    @CheckForNull
     public NodeDelegate addChild(String name) {
         Tree tree = getTree();
         return tree.hasChild(name)

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java?rev=1341047&r1=1341046&r2=1341047&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java Mon May 21 14:34:52 2012
@@ -65,7 +65,7 @@ import static org.apache.jackrabbit.oak.
 /**
  * {@code NodeImpl}...
  */
-public class NodeImpl extends ItemImpl implements Node  {
+public class NodeImpl extends ItemImpl implements Node {
 
     /**
      * logger instance
@@ -177,6 +177,10 @@ public class NodeImpl extends ItemImpl i
         // TODO: END
 
         NodeDelegate added = parent.addChild(oakName);
+        if (added == null) {
+            throw new ItemExistsException();
+        }
+
         Node childNode = new NodeImpl(added);
         childNode.setPrimaryType(primaryNodeTypeName);
         return childNode;