You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2017/04/13 15:56:32 UTC
[02/29] ignite git commit: ignite-3682: all anonymous classes were
extracted
http://git-wip-us.apache.org/repos/asf/ignite/blob/9165b0d6/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateContainWrapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateContainWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateContainWrapper.java
new file mode 100644
index 0000000..546686c
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateContainWrapper.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.util.lang.gridfunc;
+
+import java.util.Collection;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.lang.IgnitePredicate;
+
+/**
+ * Predicate which returns {@code true} if it receives an element that is contained in the passed in
+ * collection.
+ *
+ * @param <T> Type of the free variable for the predicate and type of the collection elements.
+ */
+public class IgnitePredicateContainWrapper<T> implements IgnitePredicate<T> {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ private final Collection<? extends T> c;
+
+ /**
+ * @param c Collection to check for containment.
+ */
+ public IgnitePredicateContainWrapper(Collection<? extends T> c) {
+ this.c = c;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean apply(T t) {
+ assert c != null;
+
+ return c.contains(t);
+ }
+
+ /** {@inheritDoc} */
+ public String toString() {
+ return S.toString(IgnitePredicateContainWrapper.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9165b0d6/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateEqualsClusterNodeId.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateEqualsClusterNodeId.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateEqualsClusterNodeId.java
new file mode 100644
index 0000000..4283068
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateEqualsClusterNodeId.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.util.lang.gridfunc;
+
+import java.util.UUID;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.lang.IgnitePredicate;
+
+/**
+ * Creates grid node predicate evaluating on the given node ID.
+ */
+public class IgnitePredicateEqualsClusterNodeId<T extends ClusterNode> implements IgnitePredicate<T> {
+ /** */
+ private static final long serialVersionUID = -7082730222779476623L;
+
+ /** */
+ private final UUID nodeId;
+
+ /**
+ * @param nodeId (Collection)
+ */
+ public IgnitePredicateEqualsClusterNodeId(UUID nodeId) {
+ this.nodeId = nodeId;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean apply(ClusterNode e) {
+ return e.id().equals(nodeId);
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(IgnitePredicateEqualsClusterNodeId.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9165b0d6/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateEqualsUUID.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateEqualsUUID.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateEqualsUUID.java
new file mode 100644
index 0000000..326fe95
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateEqualsUUID.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.util.lang.gridfunc;
+
+import java.util.UUID;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.lang.IgnitePredicate;
+
+/**
+ * UUID equals predicate.
+ */
+public class IgnitePredicateEqualsUUID implements IgnitePredicate<UUID> {
+ /** */
+ private static final long serialVersionUID = -5664060422647374863L;
+
+ /** */
+ private final UUID nodeId;
+
+ /**
+ * @param nodeId Node ID for which returning predicate will evaluate to {@code true}.
+ */
+ public IgnitePredicateEqualsUUID(UUID nodeId) {
+ this.nodeId = nodeId;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean apply(UUID id) {
+ return id.equals(nodeId);
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(IgnitePredicateEqualsUUID.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9165b0d6/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateEvaluateEntryByKey.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateEvaluateEntryByKey.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateEvaluateEntryByKey.java
new file mode 100644
index 0000000..a8eca85
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateEvaluateEntryByKey.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.util.lang.gridfunc;
+
+import java.util.Map;
+import org.apache.ignite.internal.util.lang.GridFunc;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.lang.IgnitePredicate;
+
+/**
+ * Predicate evaluates to true for given value.
+ * Note that evaluation will be short-circuit when first predicate evaluated to false is found.
+ */
+public class IgnitePredicateEvaluateEntryByKey<K, V> implements IgnitePredicate<Map.Entry<K, V>> {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ private final IgnitePredicate<? super K>[] predicates;
+
+ /**
+ * @param predicates Optional set of predicates to use for filtration. If none provided - original map (or its copy) will be
+ * returned.
+ */
+ public IgnitePredicateEvaluateEntryByKey(IgnitePredicate<? super K>... predicates) {
+ this.predicates = predicates;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean apply(Map.Entry<K, V> e) {
+ return GridFunc.isAll(e.getKey(), predicates);
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(IgnitePredicateEvaluateEntryByKey.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9165b0d6/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateEvaluateEntryByValue.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateEvaluateEntryByValue.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateEvaluateEntryByValue.java
new file mode 100644
index 0000000..a082c4e
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateEvaluateEntryByValue.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.util.lang.gridfunc;
+
+import java.util.Map;
+import org.apache.ignite.internal.util.lang.GridFunc;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.lang.IgnitePredicate;
+
+/**
+ * Predicate evaluates to true for given value.
+ * Note that evaluation will be short-circuit when first predicate evaluated to false is found.
+ */
+public class IgnitePredicateEvaluateEntryByValue<K, V> implements IgnitePredicate<Map.Entry<K, V>> {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ private final IgnitePredicate<? super V>[] predicates;
+
+ /**
+ * @param predicates Optional set of predicates to use for filtration. If none provided - original map (or its copy) will be
+ * returned.
+ */
+ public IgnitePredicateEvaluateEntryByValue(IgnitePredicate<? super V>... predicates) {
+ this.predicates = predicates;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean apply(Map.Entry<K, V> e) {
+ return GridFunc.isAll(e.getValue(), predicates);
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(IgnitePredicateEvaluateEntryByValue.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9165b0d6/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateHasEqualId.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateHasEqualId.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateHasEqualId.java
new file mode 100644
index 0000000..6d23ce3
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateHasEqualId.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.util.lang.gridfunc;
+
+import java.util.UUID;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.lang.IgnitePredicate;
+
+/**
+ * {@link ClusterNode} has equal id predicate.
+ */
+public class IgnitePredicateHasEqualId<T extends ClusterNode> implements IgnitePredicate<T> {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ private final UUID locNodeId;
+
+ /**
+ * @param locNodeId Id for check.
+ */
+ public IgnitePredicateHasEqualId(UUID locNodeId) {
+ this.locNodeId = locNodeId;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean apply(T n) {
+ return n.id().equals(locNodeId);
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(IgnitePredicateHasEqualId.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9165b0d6/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateHasNotEqualId.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateHasNotEqualId.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateHasNotEqualId.java
new file mode 100644
index 0000000..2381515
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateHasNotEqualId.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.util.lang.gridfunc;
+
+import java.util.UUID;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.lang.IgnitePredicate;
+
+/**
+ * {@link ClusterNode} node has NOT equal id predicate.
+ */
+public class IgnitePredicateHasNotEqualId<T extends ClusterNode> implements IgnitePredicate<T> {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ private final UUID locNodeId;
+
+ /**
+ * @param locNodeId Id for check.
+ */
+ public IgnitePredicateHasNotEqualId(UUID locNodeId) {
+ this.locNodeId = locNodeId;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean apply(T n) {
+ return !n.id().equals(locNodeId);
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(IgnitePredicateHasNotEqualId.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9165b0d6/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateIgniteFutureIsNotDone.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateIgniteFutureIsNotDone.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateIgniteFutureIsNotDone.java
new file mode 100644
index 0000000..e5f3d21
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateIgniteFutureIsNotDone.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.util.lang.gridfunc;
+
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.lang.IgnitePredicate;
+
+/**
+ * IgniteInternalFuture is not done predicate.
+ */
+public class IgnitePredicateIgniteFutureIsNotDone implements IgnitePredicate<IgniteInternalFuture<?>> {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** {@inheritDoc} */
+ @Override public boolean apply(IgniteInternalFuture<?> f) {
+ return !f.isDone();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(IgnitePredicateIgniteFutureIsNotDone.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9165b0d6/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateIsAll.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateIsAll.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateIsAll.java
new file mode 100644
index 0000000..8177d3e
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateIsAll.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.util.lang.gridfunc;
+
+import org.apache.ignite.internal.util.lang.GridFunc;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.lang.IgnitePredicate;
+
+/**
+ * Predicate that evaluates to {@code true} if each of its component predicates evaluates to {@code true}.
+ *
+ * @param <T> Type of the free variable, i.e. the element the predicate is called on.
+ */
+public class IgnitePredicateIsAll<T> implements IgnitePredicate<T> {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ private final IgnitePredicate<? super T>[] predicates;
+
+ /**
+ * @param predicates Passed in predicate. If none provided - always-{@code false} predicate is returned.
+ */
+ public IgnitePredicateIsAll(IgnitePredicate<? super T>... predicates) {
+ this.predicates = predicates;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean apply(T t) {
+ return GridFunc.isAll(t, predicates);
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(IgnitePredicateIsAll.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9165b0d6/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateIsAssignableFrom.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateIsAssignableFrom.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateIsAssignableFrom.java
new file mode 100644
index 0000000..a024d46
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateIsAssignableFrom.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.util.lang.gridfunc;
+
+import org.apache.ignite.internal.util.typedef.P1;
+import org.apache.ignite.internal.util.typedef.internal.S;
+
+/**
+ * Predicate that evaluates to {@code true} if its free variable is instance of the given class.
+ *
+ * @param <T> Type of the free variable, i.e. the element the predicate is called on.
+ */
+public class IgnitePredicateIsAssignableFrom<T> implements P1<T> {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ private final Class<?> cls;
+
+ /**
+ * @param cls Class to compare to.
+ */
+ public IgnitePredicateIsAssignableFrom(Class<?> cls) {
+ this.cls = cls;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean apply(T t) {
+ return t != null && cls.isAssignableFrom(t.getClass());
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(IgnitePredicateIsAssignableFrom.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9165b0d6/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateIsNotAll.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateIsNotAll.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateIsNotAll.java
new file mode 100644
index 0000000..51e19cd
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateIsNotAll.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.util.lang.gridfunc;
+
+import org.apache.ignite.internal.util.lang.GridFunc;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.lang.IgnitePredicate;
+
+/**
+ * Negated predicate.
+ *
+ * @param <T> Type of the free variable, i.e. the element the predicate is called on.
+ */
+public class IgnitePredicateIsNotAll<T> implements IgnitePredicate<T> {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ private final IgnitePredicate<? super T>[] predicates;
+
+ /**
+ * @param predicates Predicate to negate.
+ */
+ public IgnitePredicateIsNotAll(IgnitePredicate<? super T>... predicates) {
+ this.predicates = predicates;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean apply(T t) {
+ return !GridFunc.isAll(t, predicates);
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(IgnitePredicateIsNotAll.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9165b0d6/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateIsNull.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateIsNull.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateIsNull.java
new file mode 100644
index 0000000..499b554
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateIsNull.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.util.lang.gridfunc;
+
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.lang.IgnitePredicate;
+
+/**
+ * Defines a predicate which checks a parameter on <code>null</code>.
+ *
+ * @param <E> Type of predicate parameter.
+ */
+public class IgnitePredicateIsNull<E> implements IgnitePredicate<E> {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /**
+ * @param e Parameter for check.
+ * @return 'true' if parameter equals to <code>null</code>, otherwise 'false'.
+ */
+ @Override public boolean apply(E e) {
+ return e == null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(IgnitePredicateIsNull.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9165b0d6/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateNotContainWrapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateNotContainWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateNotContainWrapper.java
new file mode 100644
index 0000000..0dc399d
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateNotContainWrapper.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.util.lang.gridfunc;
+
+import java.util.Collection;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.lang.IgnitePredicate;
+
+/**
+ * Predicate that returns {@code true} if its free variable is not contained in given collection.
+ *
+ * @param <T> Type of the free variable for the predicate and type of the collection elements.
+ */
+public class IgnitePredicateNotContainWrapper<T> implements IgnitePredicate<T> {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ private final Collection<? extends T> c;
+
+ /**
+ * @param c Collection to check for containment.
+ */
+ public IgnitePredicateNotContainWrapper(Collection<? extends T> c) {
+ this.c = c;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean apply(T t) {
+ assert c != null;
+
+ return !c.contains(t);
+ }
+
+ /** {@inheritDoc} */
+ public String toString() {
+ return S.toString(IgnitePredicateNotContainWrapper.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9165b0d6/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateNotEqual.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateNotEqual.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateNotEqual.java
new file mode 100644
index 0000000..31a165d
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateNotEqual.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.util.lang.gridfunc;
+
+import org.apache.ignite.internal.util.lang.GridFunc;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.lang.IgnitePredicate;
+
+/**
+ * Predicate that evaluates to {@code true} if its free variable is equal to {@code target} or both are
+ * {@code null}.
+ *
+ * @param <T> Type of the free variable, i.e. the element the predicate is called on.
+ */
+public class IgnitePredicateNotEqual<T> implements IgnitePredicate<T> {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ private final T target;
+
+ /**
+ * @param target Object to compare free variable to.
+ */
+ public IgnitePredicateNotEqual(T target) {
+ this.target = target;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean apply(T t) {
+ return !GridFunc.eq(t, target);
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(IgnitePredicateNotEqual.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9165b0d6/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateNotNull.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateNotNull.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateNotNull.java
new file mode 100644
index 0000000..840ab82
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgnitePredicateNotNull.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.util.lang.gridfunc;
+
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.lang.IgnitePredicate;
+
+/**
+ * Defines a predicate which checks a parameter on <code>null</code>.
+ *
+ * @param <E> Type of predicate parameter.
+ */
+public class IgnitePredicateNotNull<E> implements IgnitePredicate<E> {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /**
+ * @param e Parameter for check.
+ * @return 'true' if parameter NOT equals to <code>null</code>, otherwise 'false'.
+ */
+ @Override public boolean apply(E e) {
+ return e != null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(IgnitePredicateNotNull.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9165b0d6/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgniteReducerAlwaysTrue.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgniteReducerAlwaysTrue.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgniteReducerAlwaysTrue.java
new file mode 100644
index 0000000..389e700
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgniteReducerAlwaysTrue.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.util.lang.gridfunc;
+
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.lang.IgniteReducer;
+
+/**
+ * Reducer which always returns {@code true} from {@link org.apache.ignite.lang.IgniteReducer#collect(Object)}
+ *
+ * @param <T> Reducer element type.
+ */
+public class IgniteReducerAlwaysTrue<T> implements IgniteReducer<T, T> {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ private final T elem;
+
+ /**
+ * @param elem Element to return from {@link org.apache.ignite.lang.IgniteReducer#reduce()} method.
+ */
+ public IgniteReducerAlwaysTrue(T elem) {
+ this.elem = elem;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean collect(T e) {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public T reduce() {
+ return elem;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(IgniteReducerAlwaysTrue.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9165b0d6/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgniteReducerIntSum.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgniteReducerIntSum.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgniteReducerIntSum.java
new file mode 100644
index 0000000..0b811a8
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgniteReducerIntSum.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.util.lang.gridfunc;
+
+import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.lang.IgniteReducer;
+
+/**
+ * Reducer that calculates sum of integer elements.
+ */
+public class IgniteReducerIntSum implements IgniteReducer<Integer, Integer> {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ private AtomicInteger sum = new AtomicInteger(0);
+
+ /** {@inheritDoc} */
+ @Override public boolean collect(Integer e) {
+ if (e != null)
+ sum.addAndGet(e);
+
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Integer reduce() {
+ return sum.get();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(IgniteReducerIntSum.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9165b0d6/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgniteReducerLongSum.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgniteReducerLongSum.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgniteReducerLongSum.java
new file mode 100644
index 0000000..a5b8f59
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgniteReducerLongSum.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.util.lang.gridfunc;
+
+import java.util.concurrent.atomic.AtomicLong;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.lang.IgniteReducer;
+
+/**
+ * Reducer that calculates sum of long integer elements.
+ */
+public class IgniteReducerLongSum implements IgniteReducer<Long, Long> {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ private AtomicLong sum = new AtomicLong(0);
+
+ /** {@inheritDoc} */
+ @Override public boolean collect(Long e) {
+ if (e != null)
+ sum.addAndGet(e);
+
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Long reduce() {
+ return sum.get();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(IgniteReducerLongSum.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9165b0d6/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgniteReducerStringConcat.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgniteReducerStringConcat.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgniteReducerStringConcat.java
new file mode 100644
index 0000000..6f64747
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgniteReducerStringConcat.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.util.lang.gridfunc;
+
+import org.apache.ignite.internal.util.lang.GridFunc;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.internal.util.typedef.internal.SB;
+import org.apache.ignite.lang.IgniteReducer;
+
+/**
+ * Reducer that concatenates strings using provided delimiter.
+ */
+public class IgniteReducerStringConcat implements IgniteReducer<String, String> {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ private final String delim;
+
+ /** */
+ private SB sb;
+
+ /** */
+ private boolean first;
+
+ /** */
+ private final Object lock;
+
+ /**
+ * @param delim Delimiter (optional).
+ */
+ public IgniteReducerStringConcat(String delim) {
+ this.delim = delim;
+ sb = new SB();
+ first = true;
+ lock = new Object();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean collect(String s) {
+ synchronized (lock) {
+ if (!first && !GridFunc.isEmpty(delim))
+ sb.a(delim);
+
+ sb.a(s);
+
+ first = false;
+ }
+
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String reduce() {
+ synchronized (lock) {
+ return sb.toString();
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(IgniteReducerStringConcat.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9165b0d6/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/MultipleIterator.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/MultipleIterator.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/MultipleIterator.java
new file mode 100644
index 0000000..c5930af
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/MultipleIterator.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.util.lang.gridfunc;
+
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+import org.apache.ignite.internal.util.typedef.internal.S;
+
+/**
+ * Concatenates multiple iterators as single one.
+ *
+ * @param <T> Elements type.
+ */
+public class MultipleIterator<T> implements Iterator<T>, Serializable {
+ /** */
+ private static final long serialVersionUID = 0;
+
+ /** */
+ private final Iterator<Iterator<T>> iters;
+
+ /** */
+ private Iterator<T> it;
+
+ /** */
+ private Iterator<T> last;
+
+ /** */
+ private T next;
+
+ /**
+ * @param iters Iterator over iterators.
+ */
+ public MultipleIterator(Iterator<Iterator<T>> iters) {
+ this.iters = iters;
+ it = iters.next();
+ advance();
+ }
+
+ /** */
+ private void advance() {
+ for (; ; ) {
+ if (it.hasNext()) {
+ next = it.next();
+
+ assert next != null;
+
+ return;
+ }
+
+ if (!iters.hasNext())
+ return;
+
+ it = iters.next();
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean hasNext() {
+ return next != null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public T next() {
+ T res = next;
+
+ if (res == null)
+ throw new NoSuchElementException();
+
+ next = null;
+
+ last = it;
+
+ advance();
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void remove() {
+ if (last == null)
+ throw new IllegalStateException();
+
+ last.remove();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(MultipleIterator.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9165b0d6/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/package-info.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/package-info.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/package-info.java
new file mode 100644
index 0000000..9361826
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * <!-- Package description. -->
+ * Contains utilities classes for {@link org.apache.ignite.internal.util.lang.GridFunc}.
+ */
+package org.apache.ignite.internal.util.lang.gridfunc;
\ No newline at end of file