[java-shib-shared] branch main updated: Add a "constant" predicate method.

Scott Cantor cantor.2 at osu.edu
Thu Jan 19 21:08:33 UTC 2023


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

scantor pushed a commit to branch main
in repository java-shib-shared.

View the commit online:
http://git.shibboleth.net/view/?p=java-shib-shared.git;a=commit;h=65a47f7328b5b94cb10d2d40d636110ebce3bb83

The following commit(s) were added to refs/heads/main by this push:
     new 65a47f73 Add a "constant" predicate method.
65a47f73 is described below

commit 65a47f7328b5b94cb10d2d40d636110ebce3bb83
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Jan 19 16:08:31 2023 -0500

    Add a "constant" predicate method.
---
 .../java/net/shibboleth/shared/logic/PredicateSupport.java | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/shib-support/src/main/java/net/shibboleth/shared/logic/PredicateSupport.java b/shib-support/src/main/java/net/shibboleth/shared/logic/PredicateSupport.java
index dd45562f..7fc97b8f 100644
--- a/shib-support/src/main/java/net/shibboleth/shared/logic/PredicateSupport.java
+++ b/shib-support/src/main/java/net/shibboleth/shared/logic/PredicateSupport.java
@@ -63,6 +63,20 @@ public final class PredicateSupport {
     @Nonnull public static <T> Predicate<T> alwaysFalse() {
         return Predicates.<T>alwaysFalse();
     }
+    
+    /**
+     * Returns a predicate that returns the value of an input parameter.
+     * 
+     * @param <T> input type
+     * @param flag flag controlling result of predicate
+     * 
+     * @return the newly constructed predicate
+     * 
+     * @since 9.0.0
+     */
+    @Nonnull public static <T> Predicate<T> constant(final boolean flag) {
+        return flag ? alwaysTrue() : alwaysFalse();
+    }
 
     /**
      * Creates a predicate that checks that all elements of an {@link Iterable} matches a given target predicate.

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


More information about the commits mailing list