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 2017/04/10 12:01:09 UTC
ignite git commit: IGNITE-4733: Removed unused methods in GridFunc
and F0 classes. This closes #1563.
Repository: ignite
Updated Branches:
refs/heads/master 4425b40f9 -> 62a3b4d71
IGNITE-4733: Removed unused methods in GridFunc and F0 classes. This closes #1563.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/62a3b4d7
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/62a3b4d7
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/62a3b4d7
Branch: refs/heads/master
Commit: 62a3b4d718cd37ab6964d757b285daa126342424
Parents: 4425b40
Author: devozerov <vo...@gridgain.com>
Authored: Mon Apr 10 15:01:01 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Mon Apr 10 15:01:01 2017 +0300
----------------------------------------------------------------------
.../org/apache/ignite/internal/util/F0.java | 196 +-----
.../ignite/internal/util/lang/GridFunc.java | 620 +------------------
2 files changed, 9 insertions(+), 807 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/62a3b4d7/modules/core/src/main/java/org/apache/ignite/internal/util/F0.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/F0.java b/modules/core/src/main/java/org/apache/ignite/internal/util/F0.java
index 130987b..497baaf 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/F0.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/F0.java
@@ -21,18 +21,11 @@ import java.util.Collection;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.processors.cache.CacheEntryPredicate;
-import org.apache.ignite.internal.processors.cache.CacheEntryPredicateAdapter;
-import org.apache.ignite.internal.processors.cache.CacheEntrySerializablePredicate;
-import org.apache.ignite.internal.processors.cache.GridCacheContext;
-import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
import org.apache.ignite.internal.util.lang.GridFunc;
import org.apache.ignite.internal.util.lang.GridNodePredicate;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.P1;
import org.apache.ignite.internal.util.typedef.internal.A;
-import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.lang.IgnitePredicate;
import org.jetbrains.annotations.Nullable;
@@ -52,6 +45,7 @@ public class F0 {
* @param <T> Type of the free variable, i.e. the element the predicate is called on.
* @return Negated predicate (not peer-deployable).
*/
+ @SuppressWarnings("unchecked")
public static <T> IgnitePredicate<T> not(@Nullable final IgnitePredicate<? super T>... p) {
return F.isAlwaysFalse(p) ? F.<T>alwaysTrue() : F.isAlwaysTrue(p) ? F.<T>alwaysFalse() : new P1<T>() {
@Override public boolean apply(T t) {
@@ -90,8 +84,6 @@ public class F0 {
public static <T> IgnitePredicate<T> notIn(@Nullable final Collection<? extends T> c) {
return F.isEmpty(c) ? GridFunc.<T>alwaysTrue() : new P1<T>() {
@Override public boolean apply(T t) {
- assert c != null;
-
return !c.contains(t);
}
};
@@ -115,151 +107,6 @@ public class F0 {
}
/**
- * @param p1 Filter1.
- * @param p2 Filter2.
- * @return And filter.
- */
- public static CacheEntryPredicate and0(@Nullable final CacheEntryPredicate[] p1,
- @Nullable final CacheEntryPredicate... p2) {
- if (CU.isAlwaysFalse0(p1) || CU.isAlwaysFalse0(p2))
- return CU.alwaysFalse0();
-
- if (CU.isAlwaysTrue0(p1) && CU.isAlwaysTrue0(p2))
- return CU.alwaysTrue0();
-
- final boolean e1 = F.isEmpty(p1);
- final boolean e2 = F.isEmpty(p2);
-
- if (e1 && e2)
- return CU.alwaysTrue0();
-
- if (e1 && !e2) {
- assert p2 != null;
-
- if (p2.length == 1)
- return p2[0];
- }
-
- if (!e1 && e2) {
- assert p1 != null;
-
- if (p1.length == 1)
- return p1[0];
- }
-
- return new CacheEntrySerializablePredicate(new CacheEntryPredicateAdapter() {
- @Override public boolean apply(GridCacheEntryEx e) {
- if (!e1) {
- assert p1 != null;
-
- for (CacheEntryPredicate p : p1)
- if (p != null && !p.apply(e))
- return false;
- }
-
- if (!e2) {
- assert p2 != null;
-
- for (CacheEntryPredicate p : p2)
- if (p != null && !p.apply(e))
- return false;
- }
-
- return true;
- }
-
- @Override public void entryLocked(boolean locked) {
- if (p1 != null) {
- for (CacheEntryPredicate p : p1) {
- if (p != null)
- p.entryLocked(locked);
- }
- }
-
- if (p2 != null) {
- for (CacheEntryPredicate p : p2) {
- if (p != null)
- p.entryLocked(locked);
- }
- }
- }
-
- @Override public void prepareMarshal(GridCacheContext ctx) throws IgniteCheckedException {
- if (!e1) {
- assert p1 != null;
-
- for (CacheEntryPredicate p : p1)
- p.prepareMarshal(ctx);
- }
-
- if (!e2) {
- assert p2 != null;
-
- for (CacheEntryPredicate p : p2)
- p.prepareMarshal(ctx);
- }
- }
- });
- }
-
- /**
- * @param p Filter1.
- * @param ps Filter2.
- * @return And filter.
- */
- public static CacheEntryPredicate and0(
- @Nullable final CacheEntryPredicate p,
- @Nullable final CacheEntryPredicate... ps) {
- if (p == null && F.isEmptyOrNulls(ps))
- return CU.alwaysTrue0();
-
- if (F.isAlwaysFalse(p) && F.isAlwaysFalse(ps))
- return CU.alwaysFalse0();
-
- if (F.isAlwaysTrue(p) && F.isAlwaysTrue(ps))
- return CU.alwaysTrue0();
-
- return new CacheEntrySerializablePredicate(new CacheEntryPredicateAdapter() {
- @Override public boolean apply(GridCacheEntryEx e) {
- assert ps != null;
-
- if (p != null && !p.apply(e))
- return false;
-
- for (CacheEntryPredicate p : ps) {
- if (p != null && !p.apply(e))
- return false;
- }
-
- return true;
- }
-
- @Override public void entryLocked(boolean locked) {
- assert ps != null;
-
- if (p != null)
- p.entryLocked(locked);
-
- for (CacheEntryPredicate p : ps) {
- if (p != null)
- p.entryLocked(locked);
- }
- }
-
- @Override public void prepareMarshal(GridCacheContext ctx) throws IgniteCheckedException {
- assert ps != null;
-
- if (p != null)
- p.prepareMarshal(ctx);
-
- for (CacheEntryPredicate p : ps)
- if (p != null)
- p.prepareMarshal(ctx);
- }
- });
- }
-
- /**
* Get a predicate (non peer-deployable) that evaluates to {@code true} if each of its component predicates
* evaluates to {@code true}. The components are evaluated in order they are supplied.
* Evaluation will be stopped as soon as first predicate evaluates to {@code false}.
@@ -272,7 +119,7 @@ public class F0 {
* @return Predicate that evaluates to {@code true} if each of its component predicates
* evaluates to {@code true}.
*/
- @SuppressWarnings({"unchecked"})
+ @SuppressWarnings({"unchecked", "ConfusingArgumentToVarargsMethod"})
public static <T> IgnitePredicate<T> and(@Nullable final IgnitePredicate<? super T>[] p1,
@Nullable final IgnitePredicate<? super T>... p2) {
if (F.isAlwaysFalse(p1) || F.isAlwaysFalse(p2))
@@ -287,16 +134,12 @@ public class F0 {
if (e1 && e2)
return F.alwaysTrue();
- if (e1 && !e2) {
- assert p2 != null;
-
+ if (e1) {
if (p2.length == 1)
return (IgnitePredicate<T>)p2[0];
}
if (!e1 && e2) {
- assert p1 != null;
-
if (p1.length == 1)
return (IgnitePredicate<T>)p1[0];
}
@@ -305,15 +148,11 @@ public class F0 {
Set<UUID> ids = new GridLeanSet<>();
if (!e1) {
- assert p1 != null;
-
for (IgnitePredicate<? super T> p : p1)
ids.addAll(((GridNodePredicate)p).nodeIds());
}
if (!e2) {
- assert p2 != null;
-
for (IgnitePredicate<? super T> p : p2)
ids.addAll(((GridNodePredicate)p).nodeIds());
}
@@ -325,16 +164,12 @@ public class F0 {
return new P1<T>() {
@Override public boolean apply(T t) {
if (!e1) {
- assert p1 != null;
-
for (IgnitePredicate<? super T> p : p1)
if (p != null && !p.apply(t))
return false;
}
if (!e2) {
- assert p2 != null;
-
for (IgnitePredicate<? super T> p : p2)
if (p != null && !p.apply(t))
return false;
@@ -359,7 +194,7 @@ public class F0 {
* @return Predicate that evaluates to {@code true} if each of its component predicates
* evaluates to {@code true}.
*/
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({"unchecked", "ConfusingArgumentToVarargsMethod", "ConstantConditions"})
public static <T> IgnitePredicate<T> and(
@Nullable final IgnitePredicate<? super T> p,
@Nullable final IgnitePredicate<? super T>... ps
@@ -428,8 +263,6 @@ public class F0 {
public static <T> IgnitePredicate<T> in(@Nullable final Collection<? extends T> c) {
return F.isEmpty(c) ? GridFunc.<T>alwaysFalse() : new P1<T>() {
@Override public boolean apply(T t) {
- assert c != null;
-
return c.contains(t);
}
};
@@ -475,31 +308,10 @@ public class F0 {
* @param ps Collection of predicates to test.
* @return {@code True} if all passed in predicates are instances of {@link GridNodePredicate} class.
*/
- public static boolean isAllNodePredicates(@Nullable Iterable<? extends IgnitePredicate<?>> ps) {
- if (F.isEmpty(ps))
- return false;
-
- assert ps != null;
-
- for (IgnitePredicate<?> p : ps)
- if (!(p instanceof GridNodePredicate))
- return false;
-
- return true;
- }
-
- /**
- * Tests if all passed in predicates are instances of {@link GridNodePredicate} class.
- *
- * @param ps Collection of predicates to test.
- * @return {@code True} if all passed in predicates are instances of {@link GridNodePredicate} class.
- */
public static boolean isAllNodePredicates(@Nullable IgnitePredicate<?>... ps) {
if (F.isEmpty(ps))
return false;
- assert ps != null;
-
for (IgnitePredicate<?> p : ps)
if (!(p instanceof GridNodePredicate))
return false;
http://git-wip-us.apache.org/repos/asf/ignite/blob/62a3b4d7/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 5eb27d3..a00abe9 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
@@ -35,14 +35,11 @@ import java.util.Set;
import java.util.UUID;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
-import java.util.concurrent.atomic.AtomicReference;
import javax.cache.Cache;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.cluster.ClusterNode;
-import org.apache.ignite.compute.ComputeJobResult;
import org.apache.ignite.internal.IgniteFutureTimeoutCheckedException;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.util.F0;
@@ -52,7 +49,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;
@@ -68,7 +64,6 @@ import org.apache.ignite.lang.IgniteBiTuple;
import org.apache.ignite.lang.IgniteCallable;
import org.apache.ignite.lang.IgniteClosure;
import org.apache.ignite.lang.IgniteInClosure;
-import org.apache.ignite.lang.IgniteOutClosure;
import org.apache.ignite.lang.IgnitePredicate;
import org.apache.ignite.lang.IgniteReducer;
import org.jetbrains.annotations.NotNull;
@@ -153,13 +148,6 @@ public class GridFunc {
};
/** */
- private static final IgnitePredicate<Object> IS_NULL = new P1<Object>() {
- @Override public boolean apply(Object o) {
- return o == null;
- }
- };
-
- /** */
private static final IgnitePredicate<Object> IS_NOT_NULL = new P1<Object>() {
@Override public boolean apply(Object o) {
return o != null;
@@ -167,28 +155,6 @@ public class GridFunc {
};
/** */
- private static final IgniteCallable<?> LIST_FACTORY = new IgniteCallable<List>() {
- @Override public List call() {
- return new ArrayList();
- }
-
- @Override public String toString() {
- return "Array list factory.";
- }
- };
-
- /** */
- private static final IgniteCallable<?> LINKED_LIST_FACTORY = new IgniteCallable<LinkedList>() {
- @Override public LinkedList call() {
- return new LinkedList();
- }
-
- @Override public String toString() {
- return "Linked list factory.";
- }
- };
-
- /** */
private static final IgniteCallable<?> SET_FACTORY = new IgniteCallable<Set>() {
@Override public Set call() {
return new HashSet();
@@ -211,39 +177,6 @@ public class GridFunc {
};
/** */
- private static final IgniteCallable<AtomicLong> ATOMIC_LONG_FACTORY = new IgniteCallable<AtomicLong>() {
- @Override public AtomicLong call() {
- return new AtomicLong(0);
- }
-
- @Override public String toString() {
- return "Atomic long factory.";
- }
- };
-
- /** */
- private static final IgniteCallable<AtomicBoolean> ATOMIC_BOOL_FACTORY = new IgniteCallable<AtomicBoolean>() {
- @Override public AtomicBoolean call() {
- return new AtomicBoolean();
- }
-
- @Override public String toString() {
- return "Atomic boolean factory.";
- }
- };
-
- /** */
- private static final IgniteCallable<?> ATOMIC_REF_FACTORY = new IgniteCallable<AtomicReference>() {
- @Override public AtomicReference call() {
- return new AtomicReference();
- }
-
- @Override public String toString() {
- return "Atomic reference factory.";
- }
- };
-
- /** */
private static final IgniteCallable<?> MAP_FACTORY = new IgniteCallable<Map>() {
@Override public Map call() {
return new HashMap();
@@ -322,35 +255,6 @@ public class GridFunc {
}
};
- /** */
- private static final IgniteClosure<ClusterNode, String> NODE2ID8 = new IgniteClosure<ClusterNode, String>() {
- @Override public String apply(ClusterNode n) {
- return U.id8(n.id());
- }
-
- @Override public String toString() {
- return "Grid node to node ID8 transformer closure.";
- }
- };
-
- /** */
- private static final IgniteClosure<UUID, String> ID2ID8 = new IgniteClosure<UUID, String>() {
- @Override public String apply(UUID id) {
- return U.id8(id);
- }
-
- @Override public String toString() {
- return "UUID to ID8 transformer closure.";
- }
- };
-
- /** */
- private static final IgnitePredicate<IgniteInternalFuture<?>> UNFINISHED_FUTURE = new IgnitePredicate<IgniteInternalFuture<?>>() {
- @Override public boolean apply(IgniteInternalFuture<?> f) {
- return !f.isDone();
- }
- };
-
/**
* Gets predicate that evaluates to {@code true} only for given local node ID.
*
@@ -562,39 +466,6 @@ public class GridFunc {
}
/**
- * Gets collections of data items from grid job res casted to specified type.
- * <p>
- * Here's the typical example of how this method is used in {@code reduce()} method
- * implementation (this example sums up all the values of {@code Integer} type):
- * <pre name="code" class="java">
- * public Integer reduce(List<ComputeJobResult> res) throws IgniteCheckedException {
- * return F.sum(F.<Integer>jobResults(res));
- * }
- * </pre>
- * <p>
- * Note that this method doesn't create a new collection but simply iterates over the input one.
- *
- * @param res Collection of grid job res.
- * @param <T> Type of the data item to cast to. See {@link org.apache.ignite.compute.ComputeJobResult#getData()} method.
- * @return Collections of data items casted to type {@code T}.
- * @see org.apache.ignite.compute.ComputeJobResult#getData()
- */
- @Deprecated
- public static <T> Collection<T> jobResults(@Nullable Collection<? extends ComputeJobResult> res) {
- if (isEmpty(res))
- return Collections.emptyList();
-
- assert res != null;
-
- Collection<T> c = new ArrayList<>(res.size());
-
- for (ComputeJobResult r : res)
- c.add(r.<T>getData());
-
- return c;
- }
-
- /**
* Convenient utility method that returns collection of node IDs for a given
* collection of grid nodes.
* <p>
@@ -612,43 +483,6 @@ public class GridFunc {
}
/**
- * Convenient utility method that returns collection of node ID8s for a given
- * collection of grid nodes. ID8 is a shorter string representation of node ID,
- * mainly the first 8 characters.
- * <p>
- * Note that this method doesn't create a new collection but simply iterates
- * over the input one.
- *
- * @param nodes Collection of grid nodes.
- * @return Collection of node IDs for given collection of grid nodes.
- */
- public static Collection<String> nodeId8s(@Nullable Collection<? extends ClusterNode> nodes) {
- if (nodes == null || nodes.isEmpty())
- return Collections.emptyList();
-
- return F.viewReadOnly(nodes, NODE2ID8);
- }
-
- /**
- * Convenient utility method that returns collection of node ID8s for a given
- * collection of node IDs. ID8 is a shorter string representation of node ID,
- * mainly the first 8 characters.
- * <p>
- * Note that this method doesn't create a new collection but simply iterates
- * over the input one.
- *
- * @param ids Collection of nodeIds.
- * @return Collection of node IDs for given collection of grid nodes.
- */
- @Deprecated
- public static Collection<String> id8s(@Nullable Collection<UUID> ids) {
- if (ids == null || ids.isEmpty())
- return Collections.emptyList();
-
- return F.viewReadOnly(ids, ID2ID8);
- }
-
- /**
* Creates absolute closure that does <tt>System.out.println(msg)</tt>.
*
* @param msg Message to print.
@@ -739,8 +573,6 @@ public class GridFunc {
return l;
}
- assert c != null;
-
Collection<T> ret = new ArrayList<>(c.size() + 1);
ret.add(t);
@@ -752,8 +584,6 @@ public class GridFunc {
if (isEmpty(c))
return Collections.singletonList(t);
- assert c != null;
-
return new GridSerializableCollection<T>() {
@NotNull
@Override public Iterator<T> iterator() {
@@ -804,6 +634,7 @@ public class GridFunc {
* @param <T> Element type.
* @return Concatenated {@code non-null} collection.
*/
+ @SuppressWarnings("ConstantConditions")
public static <T> Collection<T> concat(boolean cp, @Nullable final Collection<T> c1,
@Nullable final Collection<T> c2) {
if (cp) {
@@ -1079,55 +910,6 @@ public class GridFunc {
}
/**
- * Loses all entries in input map which keys are evaluated to {@code true} by all
- * given predicates.
- *
- * @param m Map to filter.
- * @param cp If {@code true} method creates new map not modifying input, otherwise does
- * <tt>in-place</tt> modifications.
- * @param p Optional set of predicates to use for filtration. If none provided - original
- * map (or its copy) will be returned.
- * @param <K> Type of the free variable for the predicate and type of map's keys.
- * @param <V> Type of map's values.
- * @return Filtered map.
- */
- @Deprecated
- public static <K, V> Map<K, V> loseKeys(
- Map<K, V> m,
- boolean cp,
- @Nullable final IgnitePredicate<? super K>... p
- ) {
- return lose(m, cp, new P1<Map.Entry<K, V>>() {
- @Override public boolean apply(Map.Entry<K, V> e) {
- return isAll(e.getKey(), p);
- }
- });
- }
-
- /**
- * Loses all entries in input map which values are evaluated to {@code true} by all
- * given predicates.
- *
- * @param m Map to filter.
- * @param cp If {@code true} method creates new map not modifying input, otherwise does
- * <tt>in-place</tt> modifications.
- * @param p Optional set of predicates to use for filtration. If none provided - original
- * map (or its copy) will be returned.
- * @param <K> Type of the free variable for the predicate and type of map's keys.
- * @param <V> Type of map's values.
- * @return Filtered map.
- */
- @Deprecated
- public static <K, V> Map<K, V> loseValues(Map<K, V> m, boolean cp,
- @Nullable final IgnitePredicate<? super V>... p) {
- return lose(m, cp, new P1<Map.Entry<K, V>>() {
- @Override public boolean apply(Map.Entry<K, V> e) {
- return isAll(e.getValue(), p);
- }
- });
- }
-
- /**
* Loses all elements in input list that are contained in {@code filter} collection.
*
* @param c Input list.
@@ -1138,6 +920,7 @@ public class GridFunc {
* @param <T> Type of list.
* @return List of remaining elements
*/
+ @SuppressWarnings("SuspiciousMethodCalls")
public static <T> List<T> loseList(List<T> c, boolean cp, @Nullable Collection<? super T> filter) {
A.notNull(c, "c");
@@ -1361,41 +1144,6 @@ public class GridFunc {
}
/**
- * Curries given closure.
- *
- * @param f Closure.
- * @param e Parameter.
- * @param <T> Input type.
- * @param <R> Output type.
- * @return Curried closure.
- */
- @Deprecated
- public static <T, R> IgniteOutClosure<R> curry(final IgniteClosure<? super T, R> f, final T e) {
- return new IgniteOutClosure<R>() {
- @Override public R apply() {
- return f.apply(e);
- }
- };
- }
-
- /**
- * Curries given closure.
- *
- * @param f Closure.
- * @param e Parameter.
- * @param <T> Input type.
- * @return Curried closure.
- */
- @Deprecated
- public static <T> GridAbsClosure curry(final IgniteInClosure<? super T> f, final T e) {
- return new GridAbsClosure() {
- @Override public void apply() {
- f.apply(e);
- }
- };
- }
-
- /**
* Converts array to {@link List}. Note that resulting list cannot
* be altered in size, as it it based on the passed in array -
* only current elements can be changed.
@@ -1650,8 +1398,6 @@ public class GridFunc {
if (isEmpty(c) || isAlwaysFalse(p))
return Collections.emptyList();
- assert c != null;
-
return isEmpty(p) || isAlwaysTrue(p) ? c : new GridSerializableCollection<T>() {
// Pass through (will fail for readonly).
@Override public boolean add(T e) {
@@ -1696,8 +1442,6 @@ public class GridFunc {
if (isEmpty(c) || isAlwaysFalse(p))
return Collections.emptyList();
- assert c != null;
-
return new GridSerializableCollection<T2>() {
@NotNull
@Override public Iterator<T2> iterator() {
@@ -1715,72 +1459,6 @@ public class GridFunc {
}
/**
- * Creates read-only light-weight view on given list with provided transformation.
- * Resulting list will only "have" {@code transformed} elements. Note that only wrapping
- * list will be created and no duplication of data will occur.
- *
- * @param c Input list that serves as a base for the view.
- * @param trans Transformation closure.
- * @param <T1> Type of the list.
- * @return Light-weight view on given list with provided transformation.
- */
- @SuppressWarnings("RedundantTypeArguments")
- @Deprecated
- public static <T1, T2> List<T2> viewListReadOnly(@Nullable final List<? extends T1> c,
- final IgniteClosure<? super T1, T2> trans) {
- A.notNull(trans, "trans");
-
- if (isEmpty(c))
- return Collections.emptyList();
-
- assert c != null;
-
- return new GridSerializableList<T2>() {
- /** */
- private static final long serialVersionUID = 3126625219739967068L;
-
- @Override public T2 get(int idx) {
- return trans.apply(c.get(idx));
- }
-
- @NotNull
- @Override public Iterator<T2> iterator() {
- return F.<T1, T2>iterator(c, trans, true);
- }
-
- @Override public int size() {
- return c.size();
- }
-
- @Override public boolean isEmpty() {
- return c.isEmpty();
- }
- };
- }
-
- /**
- * Creates a view on given list with provided transformer and predicates.
- * Resulting list will only "have" elements for which all provided predicates, if any,
- * evaluate to {@code true}. Note that a new collection will be created and data will
- * be copied.
- *
- * @param c Input list that serves as a base for the view.
- * @param trans Transforming closure from T1 to T2.
- * @param p Optional predicates. If predicates are not provided - all elements will be in the view.
- * @return View on given list with provided predicate.
- */
- @Deprecated
- public static <T1, T2> List<T2> transformList(Collection<? extends T1> c,
- IgniteClosure<? super T1, T2> trans, @Nullable IgnitePredicate<? super T1>... p) {
- A.notNull(c, "c", trans, "trans");
-
- if (isAlwaysFalse(p))
- return Collections.emptyList();
-
- return new ArrayList<>(transform(retain(c, true, p), trans));
- }
-
- /**
* Creates light-weight view on given map with provided predicates. Resulting map will
* only "have" keys for which all provided predicates, if any, evaluates to {@code true}.
* Note that only wrapping map will be created and no duplication of data will occur.
@@ -1798,8 +1476,6 @@ public class GridFunc {
if (isEmpty(m) || isAlwaysFalse(p))
return Collections.emptyMap();
- assert m != null;
-
return isEmpty(p) || isAlwaysTrue(p) ? m : new GridSerializableMap<K, V>() {
/** */
private static final long serialVersionUID = 5531745605372387948L;
@@ -1886,8 +1562,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<K, V1>() {
@@ -2008,8 +1682,6 @@ public class GridFunc {
if (isEmpty(m) || isAlwaysFalse(p))
return Collections.emptyMap();
- assert m != null;
-
return new GridSerializableMap<K, V1>() {
/** Entry predicate. */
private IgnitePredicate<Entry<K, V>> ep = new P1<Map.Entry<K, V>>() {
@@ -2130,8 +1802,6 @@ public class GridFunc {
if (isEmpty(c) || isAlwaysFalse(p))
return Collections.emptyMap();
- assert c != null;
-
return new GridSerializableMap<K, V>() {
/** Entry predicate. */
private IgnitePredicate<K> ep = new P1<K>() {
@@ -2313,60 +1983,6 @@ public class GridFunc {
}
/**
- * Converts collection of numbers to primitive {@code int[]} array.
- *
- * @param col Collection of numbers.
- * @return Array of integers.
- */
- public static int[] toIntArray(Collection<? extends Number> col) {
- if (col == null)
- return null;
-
- int[] res = new int[col.size()];
-
- Iterator<? extends Number> iter = col.iterator();
-
- for (int i = 0; i < res.length; i++)
- res[i] = iter.next().intValue();
-
- return res;
- }
-
- /**
- * Utility map getter. This method analogous to {@link #addIfAbsent(Map, Object, Callable)}
- * method but this one doesn't put the default value into the map when key is not found.
- *
- * @param map Map to get value from.
- * @param key Map key (can be {@code null}).
- * @param c Optional factory closure for the default value to be returned in
- * when {@code key} is not found. If closure is not provided - {@code null} will be returned.
- * @param <K> Map key type.
- * @param <V> Map value type.
- * @return Value for the {@code key} or default value produced by {@code c} if key is not
- * found (or {@code null} if key is not found and closure is not provided).
- * @throws GridClosureException Thrown in case when callable throws exception.
- * @see #newLinkedList()
- * @see #newList()
- * @see #newSet()
- * @see #newAtomicLong()
- * @see #newAtomicInt()
- * @see #newAtomicRef()
- * @see #newAtomicBoolean()
- */
- @Deprecated
- @Nullable public static <K, V> V returnIfAbsent(Map<? extends K, ? extends V> map, @Nullable K key,
- @Nullable Callable<V> c) {
- A.notNull(map, "map");
-
- try {
- return !map.containsKey(key) ? c == null ? null : c.call() : map.get(key);
- }
- catch (Exception e) {
- throw wrap(e);
- }
- }
-
- /**
* Returns a factory closure that creates new {@link ConcurrentLinkedDeque8} instance.
* Note that this method does not create a new closure but returns a static one.
*
@@ -2380,20 +1996,6 @@ public class GridFunc {
}
/**
- * Returns a factory closure that creates new {@link List} instance. Note that this
- * method does not create a new closure but returns a static one.
- *
- * @param <T> Type parameters for the created {@link List}.
- * @return Factory closure that creates new {@link List} instance every
- * time its {@link org.apache.ignite.lang.IgniteOutClosure#apply()} method is called.
- */
- @SuppressWarnings("unchecked")
- @Deprecated
- public static <T> IgniteCallable<List<T>> newList() {
- return (IgniteCallable<List<T>>)LIST_FACTORY;
- }
-
- /**
* Returns a factory closure that creates new {@link AtomicInteger} instance
* initialized to {@code zero}. Note that this method does not create a new
* closure but returns a static one.
@@ -2407,61 +2009,6 @@ public class GridFunc {
}
/**
- * Returns a factory closure that creates new {@link AtomicLong} instance
- * initialized to {@code zero}. Note that this method does not create a new
- * closure but returns a static one.
- *
- * @return Factory closure that creates new {@link AtomicLong} instance
- * initialized to {@code zero} every time its {@link org.apache.ignite.lang.IgniteOutClosure#apply()} method is called.
- */
- @Deprecated
- public static IgniteCallable<AtomicLong> newAtomicLong() {
- return ATOMIC_LONG_FACTORY;
- }
-
- /**
- * Returns a factory closure that creates new {@link AtomicReference} instance
- * initialized to {@code null}. Note that this method does not create a new closure
- * but returns a static one.
- *
- * @param <T> Type of the atomic reference.
- * @return Factory closure that creates new {@link AtomicReference} instance
- * initialized to {@code null} every time its {@link org.apache.ignite.lang.IgniteOutClosure#apply()} method is called.
- */
- @SuppressWarnings("unchecked")
- @Deprecated
- public static <T> IgniteCallable<AtomicReference<T>> newAtomicRef() {
- return (IgniteCallable<AtomicReference<T>>)ATOMIC_REF_FACTORY;
- }
-
- /**
- * Returns a factory closure that creates new {@link AtomicBoolean} instance
- * initialized to {@code false}. Note that this method does not create a new
- * closure but returns a static one.
- *
- * @return Factory closure that creates new {@link AtomicBoolean} instance
- * initialized to {@code false} every time its {@link org.apache.ignite.lang.IgniteOutClosure#apply()} method is called.
- */
- @Deprecated
- public static IgniteCallable<AtomicBoolean> newAtomicBoolean() {
- return ATOMIC_BOOL_FACTORY;
- }
-
- /**
- * Returns a factory closure that creates new {@link LinkedList} instance.
- * Note that this method does not create a new closure but returns a static one.
- *
- * @param <T> Type parameters for the created {@link LinkedList}.
- * @return Factory closure that creates new {@link LinkedList} instance every time its {@link
- * org.apache.ignite.lang.IgniteOutClosure#apply()} method is called.
- */
- @SuppressWarnings("unchecked")
- @Deprecated
- public static <T> IgniteCallable<LinkedList<T>> newLinkedList() {
- return (IgniteCallable<LinkedList<T>>)LINKED_LIST_FACTORY;
- }
-
- /**
* Returns a factory closure that creates new {@link Set} instance. Note that this
* method does not create a new closure but returns a static one.
*
@@ -2793,17 +2340,6 @@ public class GridFunc {
}
/**
- * Gets predicate that evaluates to {@code true} if its free variable is {@code null}.
- *
- * @param <T> 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}.
- */
- @Deprecated
- public static <T> IgnitePredicate<T> isNull() {
- return (IgnitePredicate<T>) IS_NULL;
- }
-
- /**
* Gets predicate that evaluates to {@code true} if its free variable is not {@code null}.
*
* @param <T> Type of the free variable, i.e. the element the predicate is called on.
@@ -2869,25 +2405,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 <T> 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.
- */
- @Deprecated
- public static <T> IgnitePredicate<T> instanceOf(final Class<?> cls) {
- A.notNull(cls, "cls");
-
- return new P1<T>() {
- @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.
@@ -2931,8 +2448,6 @@ public class GridFunc {
if (c == null)
return null;
- assert c != null;
-
if (c instanceof RandomAccess && c instanceof List) {
List<T> l = (List<T>)c;
@@ -3006,7 +2521,7 @@ public class GridFunc {
* @return Predicate that evaluates to {@code true} if each of its component predicates
* evaluates to {@code true}.
*/
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({"unchecked", "ConfusingArgumentToVarargsMethod"})
public static <T> IgnitePredicate<T> and(@Nullable final IgnitePredicate<? super T>... ps) {
if (isEmpty(ps))
return F.alwaysTrue();
@@ -3018,8 +2533,6 @@ public class GridFunc {
return F.alwaysTrue();
if (F0.isAllNodePredicates(ps)) {
- assert ps != null;
-
Set<UUID> ids = new HashSet<>();
for (IgnitePredicate<? super T> p : ps) {
@@ -3039,8 +2552,6 @@ public class GridFunc {
else {
return new P1<T>() {
@Override public boolean apply(T t) {
- assert ps != null;
-
for (IgnitePredicate<? super T> p : ps)
if (p != null && !p.apply(t))
return false;
@@ -3090,8 +2601,6 @@ public class GridFunc {
public static <T> IgnitePredicate<T> notIn(@Nullable final Collection<? extends T> c) {
return isEmpty(c) ? GridFunc.<T>alwaysTrue() : new P1<T>() {
@Override public boolean apply(T t) {
- assert c != null;
-
return !c.contains(t);
}
};
@@ -3203,13 +2712,8 @@ public class GridFunc {
* found (or {@code null} if key is not found and closure is not provided). Note that
* in case when key is not found the default value will be put into the map.
* @throws GridClosureException Thrown in case when callable throws exception.
- * @see #newLinkedList()
- * @see #newList()
* @see #newSet()
- * @see #newAtomicLong()
* @see #newAtomicInt()
- * @see #newAtomicRef()
- * @see #newAtomicBoolean()
*/
@Nullable public static <K, V> V addIfAbsent(Map<? super K, V> map, @Nullable K key,
@Nullable Callable<? extends V> c) {
@@ -3388,20 +2892,6 @@ public class GridFunc {
}
/**
- * Upcasts collection type.
- *
- * @param c Initial collection.
- * @return Resulting collection.
- */
- @SuppressWarnings("unchecked")
- @Deprecated
- public static <T extends R, R> Collection<R> upcast(Collection<T> c) {
- A.notNull(c, "c");
-
- return (Collection<R>)c;
- }
-
- /**
* Transforms an array to read only collection using provided closure.
*
* @param c Initial array to transform.
@@ -3780,8 +3270,6 @@ public class GridFunc {
if (!isEmpty(fs))
for (D e : c) {
- assert fs != null;
-
for (IgniteBiClosure<? super D, ? super B, B> f : fs)
b = f.apply(e, b);
}
@@ -4445,75 +3933,6 @@ public class GridFunc {
}
/**
- * Compares two arrays. Unlike {@code Arrays#equals(...)} method this implementation
- * checks two arrays as sets allowing the same elements to be in different indexes.
- *
- * @param a1 First array to check.
- * @param a2 Second array to check.
- * @param sorted Tells whether or not both arrays are pre-sorted so that binary
- * search could be used instead of iteration.
- * @param dups Tells whether or not arrays can contain duplicates. If arrays contain
- * duplicate the implementation will have to do double work.
- * @return {@code True} if arrays are equal, {@code false} otherwise.
- */
- @Deprecated
- public static boolean eqArray(Object[] a1, Object[] a2, boolean sorted, boolean dups) {
- if (a1 == a2)
- return true;
-
- if (a1 == null || a2 == null || a1.length != a2.length)
- return false;
-
- // Short circuit.
- if (a1.length == 1)
- return eq(a1[0], a2[0]);
-
- for (Object o1 : a1) {
- boolean found = false;
-
- if (sorted)
- found = Arrays.binarySearch(a2, o1) >= 0;
- else {
- for (Object o2 : a2) {
- if (eq(o1, o2)) {
- found = true;
-
- break;
- }
- }
- }
-
- if (!found)
- return false;
- }
-
- // If there are no dups - we can't skip checking seconds array
- // against first one.
- if (dups) {
- for (Object o2 : a2) {
- boolean found = false;
-
- if (sorted)
- found = Arrays.binarySearch(a1, o2) >= 0;
- else {
- for (Object o1 : a1) {
- if (eq(o2, o1)) {
- found = true;
-
- break;
- }
- }
- }
-
- if (!found)
- return false;
- }
- }
-
- return true;
- }
-
- /**
* Compares two {@link org.apache.ignite.cluster.ClusterNode} instances for equality.
* <p>
* Since introduction of {@link org.apache.ignite.cluster.ClusterNode} in Apache Ignite 3.0 the semantic of equality between
@@ -4583,26 +4002,6 @@ public class GridFunc {
}
/**
- * Checks if two collections passed in intersect.
- *
- * @param <E> Element type.
- * @param s1 Set1.
- * @param s2 Set2.
- * @return {@code True} if there is an intersection, {@code false} otherwise.
- */
- @Deprecated
- public static <E> boolean intersects(Iterable<E> s1, Collection<E>... s2) {
- for (E e1 : s1) {
- for (Collection<E> s : s2) {
- if (s.contains(e1))
- return true;
- }
- }
-
- return false;
- }
-
- /**
* Waits until all passed futures will be executed.
*
* @param futs Futures. If none provided - this method is no-op.
@@ -4621,7 +4020,8 @@ public class GridFunc {
* @throws IgniteCheckedException If any of the futures failed.
*/
@Deprecated
- public static <T> void awaitAll(long timeout, @Nullable Collection<IgniteInternalFuture<T>> futs) throws IgniteCheckedException {
+ public static <T> void awaitAll(long timeout, @Nullable Collection<IgniteInternalFuture<T>> futs)
+ throws IgniteCheckedException {
awaitAll(timeout, null, futs);
}
@@ -4674,14 +4074,4 @@ public class GridFunc {
return rdc == null ? null : rdc.reduce();
}
-
- /**
- * Returns predicate for filtering unfinished futures.
- *
- * @return Predicate for filtering unfinished futures.
- */
- @Deprecated
- public static IgnitePredicate<IgniteInternalFuture<?>> unfinishedFutures() {
- return UNFINISHED_FUTURE;
- }
}