jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1547060 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak: security/privilege/JcrAllCommitHook.java security/user/MembershipWriter.java util/PropertyBuilder.java
Date Mon, 02 Dec 2013 15:29:23 GMT
Author: angela
Date: Mon Dec  2 15:29:23 2013
New Revision: 1547060

URL: http://svn.apache.org/r1547060
Log:
OAK-372 : Integrate PropertyBuilder with NodeBuilder (simplify)

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/JcrAllCommitHook.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/MembershipWriter.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/PropertyBuilder.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/JcrAllCommitHook.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/JcrAllCommitHook.java?rev=1547060&r1=1547059&r2=1547060&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/JcrAllCommitHook.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/JcrAllCommitHook.java
Mon Dec  2 15:29:23 2013
@@ -65,7 +65,7 @@ class JcrAllCommitHook implements PostVa
 
                 PropertyBuilder<String> propertyBuilder;
                 if (aggregates == null) {
-                    propertyBuilder = PropertyBuilder.create(Type.NAME, REP_AGGREGATES, true);
+                    propertyBuilder = PropertyBuilder.array(Type.NAME, REP_AGGREGATES);
                 } else {
                     propertyBuilder = PropertyBuilder.copy(Type.NAME, aggregates);
                 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/MembershipWriter.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/MembershipWriter.java?rev=1547060&r1=1547059&r2=1547060&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/MembershipWriter.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/MembershipWriter.java
Mon Dec  2 15:29:23 2013
@@ -109,7 +109,7 @@ public class MembershipWriter {
                 }
                 bestTree.setProperty(JcrConstants.JCR_PRIMARYTYPE, UserConstants.NT_REP_MEMBER_REFERENCES,
NAME);
             }
-            propertyBuilder = PropertyBuilder.create(Type.WEAKREFERENCE, UserConstants.REP_MEMBERS,
true);
+            propertyBuilder = PropertyBuilder.array(Type.WEAKREFERENCE, UserConstants.REP_MEMBERS);
         } else {
             propertyBuilder = PropertyBuilder.copy(Type.WEAKREFERENCE, bestProperty);
         }
@@ -174,7 +174,7 @@ public class MembershipWriter {
         int numNodes = 0;
         for (String ref: members) {
             if (prop == null) {
-                prop = PropertyBuilder.create(Type.WEAKREFERENCE, UserConstants.REP_MEMBERS,
true);
+                prop = PropertyBuilder.array(Type.WEAKREFERENCE, UserConstants.REP_MEMBERS);
             }
             prop.addValue(ref);
             count++;

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/PropertyBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/PropertyBuilder.java?rev=1547060&r1=1547059&r2=1547060&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/PropertyBuilder.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/PropertyBuilder.java
Mon Dec  2 15:29:23 2013
@@ -16,6 +16,9 @@
  */
 package org.apache.jackrabbit.oak.util;
 
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkState;
+
 import java.math.BigDecimal;
 import java.util.List;
 
@@ -42,9 +45,6 @@ import org.apache.jackrabbit.oak.plugins
 import org.apache.jackrabbit.oak.plugins.memory.MultiStringPropertyState;
 import org.apache.jackrabbit.oak.plugins.memory.StringPropertyState;
 
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkState;
-
 /**
  * {@code PropertyBuilder} for building in memory {@code PropertyState} instances.
  * @param <T>
@@ -73,7 +73,7 @@ public class PropertyBuilder<T> {
      * @param type  type of the {@code PropertyState} instances to be built.
      * @return {@code PropertyBuilder} for {@code type}
      */
-    public static <T> PropertyBuilder scalar(Type<T> type) {
+    public static <T> PropertyBuilder<T> scalar(Type<T> type) {
         return new PropertyBuilder<T>(type);
     }
 
@@ -83,7 +83,7 @@ public class PropertyBuilder<T> {
      * @param type  type of the {@code PropertyState} instances to be built.
      * @return {@code PropertyBuilder} for {@code type}
      */
-    public static <T> PropertyBuilder array(Type<T> type) {
+    public static <T> PropertyBuilder<T> array(Type<T> type) {
         return new PropertyBuilder<T>(type).setArray();
     }
 
@@ -99,7 +99,7 @@ public class PropertyBuilder<T> {
      * @param name  initial name
      * @return {@code PropertyBuilder} for {@code type}
      */
-    public static <T> PropertyBuilder scalar(Type<T> type, String name) {
+    public static <T> PropertyBuilder<T> scalar(Type<T> type, String name)
{
         return scalar(type).setName(name);
     }
 
@@ -115,7 +115,7 @@ public class PropertyBuilder<T> {
      * @param name  initial name
      * @return {@code PropertyBuilder} for {@code type}
      */
-    public static <T> PropertyBuilder array(Type<T> type, String name) {
+    public static <T> PropertyBuilder<T> array(Type<T> type, String name)
{
         return scalar(type).setName(name).setArray();
     }
 
@@ -132,31 +132,10 @@ public class PropertyBuilder<T> {
      * @param property  initial name and values
      * @return {@code PropertyBuilder} for {@code type}
      */
-    public static <T> PropertyBuilder copy(Type<T> type, PropertyState property)
{
+    public static <T> PropertyBuilder<T> copy(Type<T> type, PropertyState
property) {
         return scalar(type).assignFrom(property);
     }
 
-    /**
-     * Create a new {@code PropertyBuilder} from the specified parameters. Depending
-     * on the {@code isArray} flag this corresponds to
-     * <pre>{@link #array(org.apache.jackrabbit.oak.api.Type, String)}</pre>
or
-     * <pre>{@link #scalar(org.apache.jackrabbit.oak.api.Type, String)}</pre>.
-     *
-     *
-     *
-     * @param type type of the {@code PropertyState} instances to be built.
-     * @param name the name of the state to be built.
-     * @param isArray
-     * @return {@code PropertyBuilder} for {@code type}.
-     */
-    public static <T> PropertyBuilder create(@Nonnull Type<T> type, @Nonnull
String name, boolean isArray) {
-        if (isArray) {
-            return array(type, name);
-        } else {
-            return scalar(type, name);
-        }
-    }
-
     public String getName() {
         return name;
     }
@@ -238,7 +217,7 @@ public class PropertyBuilder<T> {
 
     @SuppressWarnings("unchecked")
     @Nonnull
-    public PropertyBuilder assignFrom(PropertyState property) {
+    public PropertyBuilder<T> assignFrom(PropertyState property) {
         if (property != null) {
             setName(property.getName());
             if (property.isArray()) {
@@ -253,56 +232,56 @@ public class PropertyBuilder<T> {
     }
 
     @Nonnull
-    public PropertyBuilder setName(String name) {
+    public PropertyBuilder<T> setName(String name) {
         this.name = name;
         return this;
     }
 
     @Nonnull
-    public PropertyBuilder setArray() {
+    public PropertyBuilder<T> setArray() {
         isArray = true;
         return this;
     }
 
     @Nonnull
-    public PropertyBuilder setScalar() {
+    public PropertyBuilder<T> setScalar() {
         isArray = false;
         return this;
     }
 
     @Nonnull
-    public PropertyBuilder setValue(T value) {
+    public PropertyBuilder<T> setValue(T value) {
         values.clear();
         values.add(value);
         return this;
     }
 
     @Nonnull
-    public PropertyBuilder addValue(T value) {
+    public PropertyBuilder<T> addValue(T value) {
         values.add(value);
         return this;
     }
 
     @Nonnull
-    public PropertyBuilder setValue(T value, int index) {
+    public PropertyBuilder<T> setValue(T value, int index) {
         values.set(index, value);
         return this;
     }
 
     @Nonnull
-    public PropertyBuilder setValues(Iterable<T> values) {
+    public PropertyBuilder<T> setValues(Iterable<T> values) {
         this.values = Lists.newArrayList(values);
         return this;
     }
 
     @Nonnull
-    public PropertyBuilder removeValue(int index) {
+    public PropertyBuilder<T> removeValue(int index) {
         values.remove(index);
         return this;
     }
 
     @Nonnull
-    public PropertyBuilder removeValue(Object value) {
+    public PropertyBuilder<T> removeValue(Object value) {
         values.remove(value);
         return this;
     }



Mime
View raw message