Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E021B186B4 for ; Wed, 30 Dec 2015 11:41:16 +0000 (UTC) Received: (qmail 45720 invoked by uid 500); 30 Dec 2015 11:41:16 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 45640 invoked by uid 500); 30 Dec 2015 11:41:16 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 45483 invoked by uid 99); 30 Dec 2015 11:41:16 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Dec 2015 11:41:16 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 7C226E0B19; Wed, 30 Dec 2015 11:41:16 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: vozerov@apache.org To: commits@ignite.apache.org Date: Wed, 30 Dec 2015 11:41:23 -0000 Message-Id: <000091325cd34d4283aac12a8c4a0585@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [8/8] ignite git commit: IGNITE-2263: Removed unnecessary assertions. IGNITE-2263: Removed unnecessary assertions. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/aaeb383e Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/aaeb383e Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/aaeb383e Branch: refs/heads/ignite-2263 Commit: aaeb383e9e875ba9717f7aec74658387dad4ddda Parents: d777a4e Author: vozerov-gridgain Authored: Wed Dec 30 14:42:09 2015 +0300 Committer: vozerov-gridgain Committed: Wed Dec 30 14:42:09 2015 +0300 ---------------------------------------------------------------------- .../ignite/internal/util/lang/GridFunc.java | 61 ++++---------------- 1 file changed, 12 insertions(+), 49 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/aaeb383e/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 d3adce5..71eaff3 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 @@ -46,7 +46,6 @@ import org.apache.ignite.internal.util.GridLeanMap; import org.apache.ignite.internal.util.GridLeanSet; import org.apache.ignite.internal.util.GridSerializableCollection; import org.apache.ignite.internal.util.GridSerializableIterator; -import org.apache.ignite.internal.util.GridSerializableList; import org.apache.ignite.internal.util.GridSerializableMap; import org.apache.ignite.internal.util.GridSerializableSet; import org.apache.ignite.internal.util.typedef.C1; @@ -437,8 +436,6 @@ public class GridFunc { if (isEmpty(res)) return Collections.emptyList(); - assert res != null; - Collection c = new ArrayList<>(res.size()); for (ComputeJobResult r : res) @@ -574,8 +571,6 @@ public class GridFunc { return l; } - assert c != null; - Collection ret = new ArrayList<>(c.size() + 1); ret.add(t); @@ -587,8 +582,6 @@ public class GridFunc { if (isEmpty(c)) return Collections.singletonList(t); - assert c != null; - return new GridSerializableCollection() { @NotNull @Override public Iterator iterator() { @@ -645,8 +638,11 @@ public class GridFunc { if (isEmpty(c1) && isEmpty(c2)) return new ArrayList<>(0); - if (isEmpty(c1)) + if (isEmpty(c1)) { + assert c2 != null; + return new ArrayList<>(c2); + } if (isEmpty(c2)) return new ArrayList<>(c1); @@ -823,8 +819,7 @@ public class GridFunc { * @param Type of collections. * @return Collection of remaining elements */ - public static Collection lose(Collection c, boolean cp, - @Nullable Collection filter) { + public static Collection lose(Collection c, boolean cp, @Nullable Collection filter) { A.notNull(c, "c"); return lose(c, cp, F0.in(filter)); @@ -879,6 +874,7 @@ public class GridFunc { * @param Type of list. * @return List of remaining elements */ + // TODO: REMOVE! public static List loseList(List c, boolean cp, @Nullable Collection filter) { A.notNull(c, "c"); @@ -1369,8 +1365,6 @@ public class GridFunc { if (isEmpty(c) || isAlwaysFalse(p)) return Collections.emptyList(); - assert c != null; - return isEmpty(p) || isAlwaysTrue(p) ? c : new GridSerializableCollection() { // Pass through (will fail for readonly). @Override public boolean add(T e) { @@ -1415,8 +1409,6 @@ public class GridFunc { if (isEmpty(c) || isAlwaysFalse(p)) return Collections.emptyList(); - assert c != null; - return new GridSerializableCollection() { @NotNull @Override public Iterator iterator() { @@ -1451,8 +1443,6 @@ public class GridFunc { if (isEmpty(m) || isAlwaysFalse(p)) return Collections.emptyMap(); - assert m != null; - return isEmpty(p) || isAlwaysTrue(p) ? m : new GridSerializableMap() { /** */ private static final long serialVersionUID = 5531745605372387948L; @@ -1539,8 +1529,6 @@ public class GridFunc { if (isEmpty(m) || isAlwaysFalse(p)) return Collections.emptyMap(); - assert m != null; - final boolean hasPred = p != null && p.length > 0; return new GridSerializableMap() { @@ -1613,7 +1601,7 @@ public class GridFunc { @SuppressWarnings({"unchecked"}) @Nullable @Override public V1 get(Object key) { - if (isAll((K)key, p)) { + if (isAll((K) key, p)) { V v = m.get(key); if (v != null) @@ -1662,8 +1650,6 @@ public class GridFunc { if (isEmpty(c) || isAlwaysFalse(p)) return Collections.emptyMap(); - assert c != null; - return new GridSerializableMap() { /** Entry predicate. */ private IgnitePredicate ep = new P1() { @@ -2176,8 +2162,9 @@ public class GridFunc { * @param Type of the free variable, i.e. the element the predicate is called on. * @return Predicate that evaluates to {@code true} if its free variable is {@code null}. */ + @SuppressWarnings("unchecked") public static IgnitePredicate isNull() { - return (IgnitePredicate) IS_NULL; + return (IgnitePredicate)IS_NULL; } /** @@ -2186,8 +2173,9 @@ public class GridFunc { * @param Type of the free variable, i.e. the element the predicate is called on. * @return Predicate that evaluates to {@code true} if its free variable is not {@code null}. */ + @SuppressWarnings("unchecked") public static IgnitePredicate notNull() { - return (IgnitePredicate) IS_NOT_NULL; + return (IgnitePredicate)IS_NOT_NULL; } /** @@ -2265,24 +2253,6 @@ public class GridFunc { } /** - * Gets predicate that evaluates to {@code true} if its free variable is instance of the given class. - * - * @param cls Class to compare to. - * @param Type of the free variable, i.e. the element the predicate is called on. - * @return Predicate that evaluates to {@code true} if its free variable is instance - * of the given class. - */ - public static IgnitePredicate instanceOf(final Class cls) { - A.notNull(cls, "cls"); - - return new P1() { - @Override public boolean apply(T t) { - return t != null && cls.isAssignableFrom(t.getClass()); - } - }; - } - - /** * Gets first element from given collection or returns {@code null} if the collection is empty. * * @param c A collection. @@ -2322,12 +2292,11 @@ public class GridFunc { * @param Type of the collection. * @return Collections' first element or {@code null} in case if the collection is empty. */ + @SuppressWarnings("unchecked") @Nullable public static T last(@Nullable Iterable c) { if (c == null) return null; - assert c != null; - if (c instanceof RandomAccess && c instanceof List) { List l = (List)c; @@ -2412,8 +2381,6 @@ public class GridFunc { return F.alwaysTrue(); if (F0.isAllNodePredicates(ps)) { - assert ps != null; - Set ids = new HashSet<>(); for (IgnitePredicate p : ps) { @@ -2433,8 +2400,6 @@ public class GridFunc { else { return new P1() { @Override public boolean apply(T t) { - assert ps != null; - for (IgnitePredicate p : ps) if (p != null && !p.apply(t)) return false; @@ -2483,8 +2448,6 @@ public class GridFunc { public static IgnitePredicate notIn(@Nullable final Collection c) { return isEmpty(c) ? GridFunc.alwaysTrue() : new P1() { @Override public boolean apply(T t) { - assert c != null; - return !c.contains(t); } };