jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1225045 - in /jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit: state/ChangeTree.java utils/Predicates.java
Date Tue, 27 Dec 2011 22:50:27 GMT
Author: mduerig
Date: Tue Dec 27 22:50:27 2011
New Revision: 1225045

URL: http://svn.apache.org/viewvc?rev=1225045&view=rev
Log:
Microkernel based prototype of JCR implementation (WIP)
- fix hasChanges

Added:
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/utils/Predicates.java
Modified:
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/ChangeTree.java

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/ChangeTree.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/ChangeTree.java?rev=1225045&r1=1225044&r2=1225045&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/ChangeTree.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/ChangeTree.java
Tue Dec 27 22:50:27 2011
@@ -4,6 +4,7 @@ import org.apache.jackrabbit.Path;
 import org.apache.jackrabbit.json.JsonValue;
 import org.apache.jackrabbit.spi.commons.iterator.Iterators;
 import org.apache.jackrabbit.spi.commons.iterator.Predicate;
+import org.apache.jackrabbit.utils.Predicates;
 
 import javax.jcr.ItemExistsException;
 import javax.jcr.ItemNotFoundException;
@@ -305,7 +306,14 @@ public class ChangeTree {
          * properties. 
          */
         public boolean hasChanges() {
-            return !childNodes.isEmpty() || !properties.isEmpty();
+            return !properties.isEmpty()
+                || Predicates.exists(childNodes.values(), new Predicate<NodeDelta>()
{
+
+                @Override
+                public boolean evaluate(NodeDelta delta) {
+                    return delta.isTransient();
+                }
+            });
         }
 
         /**

Added: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/utils/Predicates.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/utils/Predicates.java?rev=1225045&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/utils/Predicates.java
(added)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/utils/Predicates.java
Tue Dec 27 22:50:27 2011
@@ -0,0 +1,18 @@
+package org.apache.jackrabbit.utils;
+
+import org.apache.jackrabbit.spi.commons.iterator.Predicate;
+
+public final class Predicates {
+
+    private Predicates() { }
+
+    public static <T> boolean exists(Iterable<T> elements, Predicate<T>
predicate) {
+        for (T e : elements) {
+            if (predicate.evaluate(e)) {
+                return true;
+            }
+        }
+
+        return false;
+    }
+}



Mime
View raw message