Author: mduerig Date: Wed May 30 12:38:18 2012 New Revision: 1344231 URL: http://svn.apache.org/viewvc?rev=1344231&view=rev Log: OAK-37: Use nullability annotation to enforce/document API contract
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 jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.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=1344231&r1=1344230&r2=1344231&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 Wed May 30 12:38:18 2012 @@ -93,6 +93,7 @@ public class NodeDelegate extends ItemDe return "NodeDelegate[/" + tree.getPath() + ']'; } + @Nonnull public String getIdentifier() throws InvalidItemStateException { PropertyDelegate pd = getProperty("jcr:uuid"); if (pd == null) { @@ -100,7 +101,9 @@ public class NodeDelegate extends ItemDe return getPath(); } else { - return pd.getValue().toString(); + CoreValue value = pd.getValue(); + assert value != null; // since jcr:uuid is a single valued property + return value.toString(); } } @@ -144,6 +147,7 @@ public class NodeDelegate extends ItemDe * Get the properties of the node * @return properties of the node */ + @Nonnull public Iterator<PropertyDelegate> getProperties() throws InvalidItemStateException { return propertyDelegateIterator(getTree().getProperties().iterator()); } @@ -172,6 +176,7 @@ public class NodeDelegate extends ItemDe * Get child nodes * @return child nodes of the node */ + @Nonnull public Iterator<NodeDelegate> getChildren() throws InvalidItemStateException { return nodeDelegateIterator(getTree().getChildren().iterator()); } 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=1344231&r1=1344230&r2=1344231&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 Wed May 30 12:38:18 2012 @@ -755,7 +755,9 @@ public class NodeImpl extends ItemImpl i } else { List<CoreValue> values = new ArrayList<CoreValue>(); values.add(cv); - for (CoreValue existingValue : mixins.getValues()) { + Iterable<CoreValue> existingValues = mixins.getValues(); + assert existingValues != null; // since jcr:mixinTypes is a multi valued property + for (CoreValue existingValue : existingValues) { if (!values.contains(existingValue)) { values.add(existingValue); } Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java?rev=1344231&r1=1344230&r2=1344231&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java (original) +++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java Wed May 30 12:38:18 2012 @@ -22,6 +22,7 @@ import org.apache.jackrabbit.oak.api.Tre import org.apache.jackrabbit.oak.api.Tree.Status; import org.apache.jackrabbit.oak.commons.PathUtils; +import javax.annotation.CheckForNull; import javax.annotation.Nonnull; import javax.jcr.InvalidItemStateException; import javax.jcr.Value; @@ -99,6 +100,7 @@ public class PropertyDelegate extends It * Get the value of the property * @return value or {@code null} if multi values */ + @CheckForNull public CoreValue getValue() throws InvalidItemStateException { PropertyState state = getPropertyState(); return state.isArray() ? null : state.getValue(); @@ -108,6 +110,7 @@ public class PropertyDelegate extends It * Get the value of the property * @return value or {@code null} if single valued */ + @CheckForNull public Iterable<CoreValue> getValues() throws InvalidItemStateException { PropertyState state = getPropertyState(); return state == null ? null : state.getValues(); @@ -125,6 +128,7 @@ public class PropertyDelegate extends It * Get the property definition of the property * @return */ + @Nonnull public PropertyDefinition getDefinition() { // TODO return new PropertyDefinition() { Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java?rev=1344231&r1=1344230&r2=1344231&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java (original) +++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java Wed May 30 12:38:18 2012 @@ -70,6 +70,9 @@ public class SessionDelegate { private boolean isAlive = true; SessionDelegate(Repository repository, ContentSession contentSession) throws RepositoryException { + assert repository != null; + assert contentSession != null; + this.repository = repository; this.contentSession = contentSession; this.valueFactory = new ValueFactoryImpl(contentSession.getCoreValueFactory(), namePathMapper); @@ -88,6 +91,7 @@ public class SessionDelegate { return session; } + @Nonnull public AuthInfo getAuthInfo() { return contentSession.getAuthInfo(); }