You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2015/12/30 11:33:36 UTC
[3/5] ignite git commit: IGNITE-2263: Optimzied shortcut for "isAll"
method.
IGNITE-2263: Optimzied shortcut for "isAll" method.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/cdd8cf15
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/cdd8cf15
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/cdd8cf15
Branch: refs/heads/ignite-2263
Commit: cdd8cf154698581a399c5a42b97e8aa8fe9f95de
Parents: 9bd3150
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Dec 30 13:31:06 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Dec 30 13:31:06 2015 +0300
----------------------------------------------------------------------
.../org/apache/ignite/internal/util/lang/GridFunc.java | 12 ++++++++++++
1 file changed, 12 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/cdd8cf15/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
index 9be08a7..a412716 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
@@ -2656,6 +2656,17 @@ public class GridFunc {
}
/**
+ * Shortcut for {@link #isAll(Object, org.apache.ignite.lang.IgnitePredicate[])} method with only single predicate.
+ *
+ * @param t Value to test.
+ * @param p Predicate.
+ * @return {@code True} if test is passed.
+ */
+ public static <T> boolean isAll(@Nullable T t, @Nullable IgnitePredicate<? super T> p) {
+ return p == null || p.apply(t);
+ }
+
+ /**
* Tests if all provided predicates evaluate to {@code true} for given value. Note that
* evaluation will be short-circuit when first predicate evaluated to {@code false} is found.
*
@@ -2666,6 +2677,7 @@ public class GridFunc {
* @return Returns {@code true} if given set of predicates is {@code null}, is empty, or all predicates
* evaluate to {@code true} for given value, {@code false} otherwise.
*/
+ @SuppressWarnings("unchecked")
public static <T> boolean isAll(@Nullable T t, @Nullable IgnitePredicate<? super T>... p) {
if (p != null)
for (IgnitePredicate<? super T> r : p)