[java-support] branch master updated: Add static factory methods to simplify bean construction.

Scott Cantor cantor.2 at osu.edu
Wed Aug 24 08:18:27 EDT 2016


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch master
in repository java-support.

View the commit online:
http://git.shibboleth.net/view/?p=java-support.git;a=commit;h=1f5a8b82fb366a98833917ec20d22e29bc8b8be5

The following commit(s) were added to refs/heads/master by this push:
       new  1f5a8b8   Add static factory methods to simplify bean construction.
1f5a8b8 is described below

commit 1f5a8b82fb366a98833917ec20d22e29bc8b8be5
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Aug 24 08:18:24 2016 -0400

    Add static factory methods to simplify bean construction.
---
 .../support/logic/StrategyIndirectedPredicate.java | 34 ++++++++++++++++++++--
 1 file changed, 31 insertions(+), 3 deletions(-)

diff --git a/src/main/java/net/shibboleth/utilities/java/support/logic/StrategyIndirectedPredicate.java b/src/main/java/net/shibboleth/utilities/java/support/logic/StrategyIndirectedPredicate.java
index 2a1fc81..3b0a2e1 100644
--- a/src/main/java/net/shibboleth/utilities/java/support/logic/StrategyIndirectedPredicate.java
+++ b/src/main/java/net/shibboleth/utilities/java/support/logic/StrategyIndirectedPredicate.java
@@ -22,8 +22,6 @@ import java.util.Collection;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
-import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
-
 import com.google.common.base.Function;
 import com.google.common.base.Predicate;
 import com.google.common.base.Predicates;
@@ -63,7 +61,7 @@ public class StrategyIndirectedPredicate<T1,T2> implements Predicate<T1> {
      * @param collection a collection to test for containment
      */
     public StrategyIndirectedPredicate(@Nonnull final Function<T1,T2> objectStrategy,
-            @Nonnull @NonnullElements final Collection<T2> collection) {
+            @Nonnull final Collection<T2> collection) {
         objectLookupStrategy = Constraint.isNotNull(objectStrategy, "Object lookup strategy cannot be null");
         predicate = Predicates.in(collection);
     }
@@ -73,5 +71,35 @@ public class StrategyIndirectedPredicate<T1,T2> implements Predicate<T1> {
     public boolean apply(@Nullable final T1 input) {
         return predicate.apply(objectLookupStrategy.apply(input));
     }
+    
+    /**
+     * Factory method for predicate-based constructor.
+     * 
+     * @param objectStrategy the lookup strategy for object
+     * @param pred the predicate to apply
+     * 
+     * @return a suitably constructed predicate
+     * 
+     * @since 7.3.0
+     */
+    @Nonnull public static StrategyIndirectedPredicate forPredicate(@Nonnull final Function objectStrategy,
+            @Nonnull final Predicate pred) {
+        return new StrategyIndirectedPredicate(objectStrategy, pred);
+    }
+
+    /**
+     * Factory method for collection-based constructor.
+     * 
+     * @param objectStrategy the lookup strategy for object
+     * @param collection a collection to test for containment
+     * 
+     * @return a suitably constructed predicate
+     * 
+     * @since 7.3.0
+     */
+    @Nonnull public static StrategyIndirectedPredicate forCollection(@Nonnull final Function objectStrategy,
+            @Nonnull final Collection collection) {
+        return new StrategyIndirectedPredicate(objectStrategy, collection);
+    }
 
 }
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list