jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1342220 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak: api/PropertyState.java kernel/PropertyStateImpl.java plugins/memory/MemoryChildNodeEntry.java plugins/name/NamespaceMappings.java
Date Thu, 24 May 2012 12:20:48 GMT
Author: mduerig
Date: Thu May 24 12:20:47 2012
New Revision: 1342220

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

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/PropertyState.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/PropertyStateImpl.java
    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/name/NamespaceMappings.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/PropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/PropertyState.java?rev=1342220&r1=1342219&r2=1342220&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/PropertyState.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/PropertyState.java
Thu May 24 12:20:47 2012
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.oak.api;
 
+import javax.annotation.Nonnull;
+
 /**
  * Immutable property state. A property consists of a name and
  * a JSON-encoded value.
@@ -34,6 +36,7 @@ public interface PropertyState {
     /**
      * @return the name of this property state
      */
+    @Nonnull
     String getName();
 
     /**

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/PropertyStateImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/PropertyStateImpl.java?rev=1342220&r1=1342219&r2=1342220&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/PropertyStateImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/PropertyStateImpl.java
Thu May 24 12:20:47 2012
@@ -31,16 +31,20 @@ public class PropertyStateImpl implement
     private final CoreValue value;
     private final List<CoreValue> values;
 
-    public PropertyStateImpl(String name, CoreValue value) {
+    private PropertyStateImpl(String name, CoreValue value, List<CoreValue> values)
{
+        assert name != null;
+
         this.name = name;
         this.value = value;
-        this.values = null;
+        this.values = values;
+    }
+
+    public PropertyStateImpl(String name, CoreValue value) {
+        this(name, value, null);
     }
 
     public PropertyStateImpl(String name, List<CoreValue> values) {
-        this.name = name;
-        this.value = null;
-        this.values = Collections.unmodifiableList(values);
+        this(name, null, Collections.unmodifiableList(values));
     }
 
     @Override

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=1342220&r1=1342219&r2=1342220&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 12:20:47 2012
@@ -32,12 +32,13 @@ import java.util.Map.Entry;
  * Basic JavaBean implementation of a child node entry.
  */
 public class MemoryChildNodeEntry extends AbstractChildNodeEntry {
+    private final String name;
+    private final NodeState node;
 
     public static Iterator<ChildNodeEntry> iterator(
             final Iterator<Entry<String, NodeState>> iterator) {
 
         return Iterators.map(iterator,
-
                 new Function1<Entry<String, NodeState>, ChildNodeEntry>() {
             @Override
             public ChildNodeEntry apply(Entry<String, NodeState> entry) {
@@ -46,10 +47,6 @@ public class MemoryChildNodeEntry extend
         });
     }
 
-    private final String name;
-
-    private final NodeState node;
-
     /**
      * Creates a child node entry with the given name and referenced
      * child node state.
@@ -58,12 +55,8 @@ 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");
-        }
+        assert name != null;
+        assert node != null;
 
         this.name = name;
         this.node = node;

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/NamespaceMappings.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/NamespaceMappings.java?rev=1342220&r1=1342219&r2=1342220&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/NamespaceMappings.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/NamespaceMappings.java
Thu May 24 12:20:47 2012
@@ -16,21 +16,20 @@
 */
 package org.apache.jackrabbit.oak.plugins.name;
 
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
-
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.ContentSession;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.api.Tree;
 
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
 /**
  * Prove of concept implementation for OAK-61.
  *
@@ -103,6 +102,7 @@ public class NamespaceMappings {
         Tree namespaces = getNamespaces(session.getCurrentRoot(), false);
         if (namespaces != null) {
             for (PropertyState property : namespaces.getProperties()) {
+                // TODO: check property.isArray and log internal error if so
                 uris.add(property.getValue().getString());
             }
         }
@@ -129,6 +129,7 @@ public class NamespaceMappings {
         if (namespaces != null) {
             PropertyState property = namespaces.getProperty(prefix);
             if (property != null) {
+                // TODO: check property.isArray and log internal error if so
                 return property.getValue().getString();
             }
         }
@@ -154,6 +155,7 @@ public class NamespaceMappings {
         if (namespaces != null) {
             for (PropertyState property : namespaces.getProperties()) {
                 if (uri.equals(property.getValue().getString())) {
+                    // TODO: check property.isArray and log internal error if so
                     return property.getName();
                 }
             }



Mime
View raw message