You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by je...@apache.org on 2018/06/14 13:14:54 UTC

[sling-whiteboard] 02/02: cleaning up predicates

This is an automated email from the ASF dual-hosted git repository.

jeb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git

commit 71dee9a7a1b3d9130ba3db36c7af7528cf3a9175
Author: JE Bailey <ja...@sas.com>
AuthorDate: Wed Jun 13 16:05:20 2018 -0400

    cleaning up predicates
---
 .../resource/predicates/ChildResourcePredicates.java   | 18 +-----------------
 .../sling/resource/predicates/PropertyPredicates.java  | 14 +++++++-------
 2 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/resource-predicates/src/main/java/org/apache/sling/resource/predicates/ChildResourcePredicates.java b/resource-predicates/src/main/java/org/apache/sling/resource/predicates/ChildResourcePredicates.java
index b9b5e56..ef486af 100644
--- a/resource-predicates/src/main/java/org/apache/sling/resource/predicates/ChildResourcePredicates.java
+++ b/resource-predicates/src/main/java/org/apache/sling/resource/predicates/ChildResourcePredicates.java
@@ -14,21 +14,6 @@
 package org.apache.sling.resource.predicates;
 
 import java.util.Objects;
-/*
- * Copyright 2016 Jason E Bailey
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
 import java.util.function.Predicate;
 
 import org.apache.sling.api.resource.Resource;
@@ -44,7 +29,6 @@ public class ChildResourcePredicates {
 
     private ChildResourcePredicates(String name) {
         this.name = Objects.requireNonNull(name, "name value may not be null");
-        ;
     }
 
     /**
@@ -55,7 +39,7 @@ public class ChildResourcePredicates {
      *            of the expected child resource
      * @return Object providing helper predicates for a child resource
      */
-    static public ChildResourcePredicates child(String name) {
+    public static ChildResourcePredicates child(String name) {
         return new ChildResourcePredicates(name);
     }
 
diff --git a/resource-predicates/src/main/java/org/apache/sling/resource/predicates/PropertyPredicates.java b/resource-predicates/src/main/java/org/apache/sling/resource/predicates/PropertyPredicates.java
index c238ab3..2a3c587 100644
--- a/resource-predicates/src/main/java/org/apache/sling/resource/predicates/PropertyPredicates.java
+++ b/resource-predicates/src/main/java/org/apache/sling/resource/predicates/PropertyPredicates.java
@@ -46,7 +46,6 @@ public class PropertyPredicates {
 
     private PropertyPredicates(String name) {
         this.key = Objects.requireNonNull(name, "value may not be null");
-        ;
     }
 
     /**
@@ -56,7 +55,7 @@ public class PropertyPredicates {
      *            key value of the property
      * @return PropertyPredicate instance
      */
-    static public PropertyPredicates property(String name) {
+    public static PropertyPredicates property(String name) {
         return new PropertyPredicates(name);
     }
 
@@ -122,7 +121,7 @@ public class PropertyPredicates {
             @SuppressWarnings("unchecked")
             T propValue = (T) valueMapOf(resource).get(key, type.getClass());
             if (propValue instanceof Comparable<?>) {
-                return ((Comparable<T>) propValue).compareTo(type) > 0;
+                return propValue.compareTo(type) > 0;
             }
             return type.equals(propValue);
         };
@@ -139,7 +138,7 @@ public class PropertyPredicates {
             @SuppressWarnings("unchecked")
             T propValue = (T) valueMapOf(resource).get(key, type.getClass());
             if (propValue instanceof Comparable<?>) {
-                return ((Comparable<T>) propValue).compareTo(type) >= 0;
+                return propValue.compareTo(type) >= 0;
             }
             return type.equals(propValue);
         };
@@ -156,7 +155,7 @@ public class PropertyPredicates {
             @SuppressWarnings("unchecked")
             T propValue = (T) valueMapOf(resource).get(key, type.getClass());
             if (propValue instanceof Comparable<?>) {
-                return ((Comparable<T>) propValue).compareTo(type) < 0;
+                return propValue.compareTo(type) < 0;
             }
             return type.equals(propValue);
         };
@@ -173,7 +172,7 @@ public class PropertyPredicates {
             @SuppressWarnings("unchecked")
             T propValue = (T) valueMapOf(resource).get(key, type.getClass());
             if (propValue instanceof Comparable<?>) {
-                return ((Comparable<T>) propValue).compareTo(type) >= 0;
+                return propValue.compareTo(type) >= 0;
             }
             return type.equals(propValue);
         };
@@ -208,6 +207,7 @@ public class PropertyPredicates {
                 return false;
             }
             // validate that all items in values have matches in properties
+            
             for (T item : values) {
                 innerloop: {
                     for (T propItem : propValues) {
@@ -318,7 +318,7 @@ public class PropertyPredicates {
         if (resource == null || ResourceUtil.isNonExistingResource(resource)) {
             return ValueMap.EMPTY;
         }
-        return resource.adaptTo(ValueMap.class);
+        return resource.getValueMap();
     }
 
 }

-- 
To stop receiving notification emails like this one, please contact
jeb@apache.org.