jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1342233 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/api/ oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/
Date Thu, 24 May 2012 12:46:24 GMT
Author: mduerig
Date: Thu May 24 12:46:24 2012
New Revision: 1342233

URL: http://svn.apache.org/viewvc?rev=1342233&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/KernelNodeStoreBranch.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/PropertyStateImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.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=1342233&r1=1342232&r2=1342233&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:46:24 2012
@@ -46,15 +46,19 @@ public interface PropertyState {
     boolean isArray();
 
     /**
-     * @return  the single value of this property or {@code null} if this is a multi
-     * valued property.
+     * Value of this property.
+     * @return  the single value of this property.
+     * @throws IllegalStateException  if {@code isArray()} is {@code true}.
      */
+    @Nonnull
     CoreValue getValue();
 
     /**
-     * @return  an iterable of the values of this multi valued property or
-     * {@code null} if this is not a multi valued property.
+     * Values of this property.
+     * @return  an iterable of the values of this multi valued property.
+     * @throws IllegalStateException  if {@code isArray()} is {@code false}.
      */
+    @Nonnull
     Iterable<CoreValue> getValues();
 
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java?rev=1342233&r1=1342232&r2=1342233&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java
Thu May 24 12:46:24 2012
@@ -214,10 +214,7 @@ class KernelNodeStoreBranch implements N
                 jsop.append('{');
                 String comma = "";
                 for (PropertyState property : nodeState.getProperties()) {
-                    String value = property.isArray()
-                            ? CoreValueMapper.toJsonArray(property.getValues())
-                            : CoreValueMapper.toJsonValue(property.getValue());
-
+                    String value = toJson(property);
                     jsop.append(comma);
                     comma = ",";
                     jsop.append('"').append(property.getName()).append("\":").append(value);

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=1342233&r1=1342232&r2=1342233&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:46:24 2012
@@ -59,11 +59,17 @@ public class PropertyStateImpl implement
     
     @Override
     public CoreValue getValue() {
+        if (value == null) {
+            throw new IllegalStateException("Not a single valued property");
+        }
         return value;
     }
 
     @Override
     public Iterable<CoreValue> getValues() {
+        if (values == null) {
+            throw new IllegalStateException("Not a multi valued property");
+        }
         return values;
     }
 

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=1342233&r1=1342232&r2=1342233&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
Thu May 24 12:46:24 2012
@@ -100,7 +100,8 @@ public class PropertyDelegate extends It
      * @return  value or {@code null} if multi values
      */
     public CoreValue getValue() {
-        return getPropertyState().getValue();
+        PropertyState state = getPropertyState();
+        return state.isArray() ? null : state.getValue();
     }
 
     /**
@@ -108,7 +109,8 @@ public class PropertyDelegate extends It
      * @return  value or {@code null} if single valued
      */
     public Iterable<CoreValue> getValues() {
-        return getPropertyState().getValues();
+        PropertyState state = getPropertyState();
+        return state == null ? null : state.getValues();
     }
 
     /**



Mime
View raw message