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:39 UTC
[09/29] ignite git commit: ignite-3682: fixes of notes; refactoring
http://git-wip-us.apache.org/repos/asf/ignite/blob/a3f845b0/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/FlatIterator.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/FlatIterator.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/FlatIterator.java
new file mode 100644
index 0000000..d890e32
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/FlatIterator.java
@@ -0,0 +1,102 @@
+/*
+ * 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.Iterator;
+import java.util.NoSuchElementException;
+import org.apache.ignite.internal.util.lang.GridIteratorAdapter;
+import org.apache.ignite.internal.util.typedef.internal.S;
+
+/**
+ * Iterator over the elements of given iterators.
+ *
+ * @param <T> Type of the inner iterators.
+ */
+public class FlatIterator<T> extends GridIteratorAdapter<T> {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ private Iterator<?> iter;
+
+ /** */
+ private Iterator<T> next;
+
+ /** */
+ private boolean moved;
+
+ /** */
+ private boolean more;
+
+ /**
+ * @param iterable Input iterable of iterators.
+ */
+ public FlatIterator(Iterable<?> iterable) {
+ iter = iterable.iterator();
+ moved = true;
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Override public boolean hasNextX() {
+ if (!moved)
+ return more;
+
+ moved = false;
+
+ if (next != null && next.hasNext())
+ return more = true;
+
+ while (iter.hasNext()) {
+ if (iter instanceof Iterable)
+ next = (Iterator)((Iterable)iter).iterator().next();
+ else if (iter instanceof Iterator)
+ next = (Iterator)((Iterator)iter).next();
+ else
+ assert false : "Iterable or Iterator are expected";
+
+ if (next.hasNext())
+ return more = true;
+ }
+
+ return more = false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public T nextX() {
+ if (hasNext()) {
+ moved = true;
+
+ return next.next();
+ }
+
+ throw new NoSuchElementException();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void removeX() {
+ assert next != null;
+
+ next.remove();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(FlatIterator.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a3f845b0/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridAbsClosureNoOperation.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridAbsClosureNoOperation.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridAbsClosureNoOperation.java
deleted file mode 100644
index 196df80..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridAbsClosureNoOperation.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.GridAbsClosure;
-import org.apache.ignite.internal.util.typedef.internal.S;
-
-/**
- * Absolute closure that does nothing.
- */
-public class GridAbsClosureNoOperation extends GridAbsClosure {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** {@inheritDoc} */
- @Override public void apply() {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(GridAbsClosureNoOperation.class, this);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a3f845b0/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridAbsClosurePrint.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridAbsClosurePrint.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridAbsClosurePrint.java
deleted file mode 100644
index 33070f5..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridAbsClosurePrint.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.GridAbsClosure;
-import org.apache.ignite.internal.util.typedef.internal.S;
-
-/**
- * Absolute closure that print message.
- */
-public class GridAbsClosurePrint extends GridAbsClosure {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** */
- private String message;
-
- /**
- * @param message Message to print.
- */
- public GridAbsClosurePrint(String message) {
- this.message = message;
- }
-
- /** {@inheritDoc} */
- @Override public void apply() {
- System.out.println(message);
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(GridAbsClosurePrint.class, this);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a3f845b0/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridAbsClosureRunnableWrapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridAbsClosureRunnableWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridAbsClosureRunnableWrapper.java
deleted file mode 100644
index 6fa98f8..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridAbsClosureRunnableWrapper.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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.GridAbsClosure;
-import org.apache.ignite.internal.util.typedef.internal.S;
-
-/**
- * Closure that wraps given runnable.
- * Note that wrapping closure always returns {@code null}.
- */
-public class GridAbsClosureRunnableWrapper extends GridAbsClosure {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** */
- private final Runnable r;
-
- /**
- * @param r Runnable to convert to closure. If {@code null} - no-op closure is returned.
- */
- public GridAbsClosureRunnableWrapper(Runnable r) {
- this.r = r;
- }
-
- /** {@inheritDoc} */
- @Override public void apply() {
- if (r != null)
- r.run();
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(GridAbsClosureRunnableWrapper.class, this);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a3f845b0/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridAbsClosureWrapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridAbsClosureWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridAbsClosureWrapper.java
deleted file mode 100644
index 9902e2b..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridAbsClosureWrapper.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.GridAbsClosure;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.lang.IgniteInClosure;
-
-/**
- * Wraps given closure.
- *
- * @param <T> Input type.
- */
-public class GridAbsClosureWrapper<T> extends GridAbsClosure {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** */
- private final IgniteInClosure<? super T> closure;
-
- /** */
- private final T closureArgument;
-
- /**
- * @param closure Closure.
- * @param closureArgument Closure argument.
- */
- public GridAbsClosureWrapper(IgniteInClosure<? super T> closure, T closureArgument) {
- this.closure = closure;
- this.closureArgument = closureArgument;
- }
-
- /** {@inheritDoc} */
- @Override public void apply() {
- closure.apply(closureArgument);
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(GridAbsClosureWrapper.class, this);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a3f845b0/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridIteratorAdapterClosurePredicatesWrapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridIteratorAdapterClosurePredicatesWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridIteratorAdapterClosurePredicatesWrapper.java
deleted file mode 100644
index eeb31b3..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridIteratorAdapterClosurePredicatesWrapper.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * 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.Iterator;
-import java.util.NoSuchElementException;
-import org.apache.ignite.internal.util.lang.GridFunc;
-import org.apache.ignite.internal.util.lang.GridIteratorAdapter;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.lang.IgniteClosure;
-import org.apache.ignite.lang.IgnitePredicate;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Iterator from given iterator and optional filtering predicate.
- */
-public class GridIteratorAdapterClosurePredicatesWrapper<T2, T1> extends GridIteratorAdapter<T2> {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** */
- private final IgniteClosure<? super T1, T2> transformer;
-
- /** */
- private final boolean readOnly;
-
- /** */
- private final IgnitePredicate<? super T1>[] predicates;
-
- /** */
- private T1 elem;
-
- /** */
- private boolean more;
-
- /** */
- private boolean moved;
-
- /** */
- private Iterator<? extends T1> iterator;
-
- /**
- * @param iterator Input iterator.
- * @param transformer Transforming closure to convert from T1 to T2.
- * @param readOnly If {@code true}, then resulting iterator will not allow modifications to the underlying
- * collection.
- * @param predicates Optional filtering predicates.
- */
- public GridIteratorAdapterClosurePredicatesWrapper(Iterator<? extends T1> iterator, IgniteClosure<? super T1, T2> transformer,
- boolean readOnly,
- IgnitePredicate<? super T1>... predicates) {
- this.transformer = transformer;
- this.readOnly = readOnly;
- this.predicates = predicates;
- this.iterator = iterator;
- this.moved = true;
- }
-
- /** {@inheritDoc} */
- @Override public boolean hasNextX() {
- if (GridFunc.isEmpty(predicates))
- return iterator.hasNext();
- else {
- if (!moved)
- return more;
- else {
- more = false;
-
- while (iterator.hasNext()) {
- elem = iterator.next();
-
- boolean isAll = true;
-
- for (IgnitePredicate<? super T1> r : predicates)
- if (r != null && !r.apply(elem)) {
- isAll = false;
-
- break;
- }
-
- if (isAll) {
- more = true;
- moved = false;
-
- return true;
- }
- }
-
- elem = null; // Give to GC.
-
- return false;
- }
- }
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public T2 nextX() {
- if (GridFunc.isEmpty(predicates))
- return transformer.apply(iterator.next());
- else {
- if (hasNext()) {
- moved = true;
-
- return transformer.apply(elem);
- }
- else
- throw new NoSuchElementException();
- }
- }
-
- /** {@inheritDoc} */
- @Override public void removeX() {
- if (readOnly)
- throw new UnsupportedOperationException("Cannot modify read-only iterator.");
-
- iterator.remove();
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(GridIteratorAdapterClosurePredicatesWrapper.class, this);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a3f845b0/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridIteratorAdapterWrapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridIteratorAdapterWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridIteratorAdapterWrapper.java
deleted file mode 100644
index 22e2033..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridIteratorAdapterWrapper.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * 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.Iterator;
-import java.util.NoSuchElementException;
-import org.apache.ignite.internal.util.lang.GridIteratorAdapter;
-import org.apache.ignite.internal.util.typedef.internal.S;
-
-/**
- * Iterator over the elements of given iterators.
- *
- * @param <T> Type of the inner iterators.
- */
-public class GridIteratorAdapterWrapper<T> extends GridIteratorAdapter<T> {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** */
- private final Iterable<Iterator<T>> iterable;
-
- /** */
- private Iterator<? extends Iterator<T>> iterator;
-
- /** */
- private Iterator<T> next;
-
- /** */
- private boolean moved;
-
- /** */
- private boolean more;
-
- /**
- * @param iterable Input iterable of iterators.
- */
- public GridIteratorAdapterWrapper(Iterable<Iterator<T>> iterable) {
- this.iterable = iterable;
- iterator = iterable.iterator();
- moved = true;
- }
-
- /** {@inheritDoc} */
- @Override public boolean hasNextX() {
- if (!moved)
- return more;
-
- moved = false;
-
- if (next != null && next.hasNext())
- return more = true;
-
- while (iterator.hasNext()) {
- next = iterator.next();
-
- if (next.hasNext())
- return more = true;
- }
-
- return more = false;
- }
-
- /** {@inheritDoc} */
- @Override public T nextX() {
- if (hasNext()) {
- moved = true;
-
- return next.next();
- }
-
- throw new NoSuchElementException();
- }
-
- /** {@inheritDoc} */
- @Override public void removeX() {
- assert next != null;
-
- next.remove();
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(GridIteratorAdapterWrapper.class, this);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a3f845b0/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridIteratorOverInnerCollectionsAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridIteratorOverInnerCollectionsAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridIteratorOverInnerCollectionsAdapter.java
deleted file mode 100644
index c309232..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridIteratorOverInnerCollectionsAdapter.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * 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.Iterator;
-import java.util.NoSuchElementException;
-import org.apache.ignite.internal.util.lang.GridIteratorAdapter;
-import org.apache.ignite.internal.util.typedef.internal.S;
-
-/**
- * Wrapper wich iterable over the elements of the inner collections.
- *
- * @param <T> Type of the inner collections.
- */
-public class GridIteratorOverInnerCollectionsAdapter<T> extends GridIteratorAdapter<T> {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** */
- private final Iterable<? extends Iterable<T>> iterable;
-
- /** */
- private Iterator<? extends Iterable<T>> iterator;
-
- /** */
- private Iterator<T> next;
-
- /** */
- private boolean moved;
-
- /** */
- private boolean more;
-
- /**
- * @param iterable Input collection of collections.
- */
- public GridIteratorOverInnerCollectionsAdapter(Iterable<? extends Iterable<T>> iterable) {
- this.iterable = iterable;
- iterator = iterable.iterator();
- moved = true;
- }
-
- /** {@inheritDoc} */
- @Override public boolean hasNextX() {
- if (!moved)
- return more;
-
- moved = false;
-
- if (next != null && next.hasNext())
- return more = true;
-
- while (iterator.hasNext()) {
- next = iterator.next().iterator();
-
- if (next.hasNext())
- return more = true;
- }
-
- return more = false;
- }
-
- /** {@inheritDoc} */
- @Override public T nextX() {
- if (hasNext()) {
- moved = true;
-
- return next.next();
- }
-
- throw new NoSuchElementException();
- }
-
- /** {@inheritDoc} */
- @Override public void removeX() {
- assert next != null;
-
- next.remove();
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(GridIteratorOverInnerCollectionsAdapter.class, this);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a3f845b0/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridSerializableCollectionPredicateWrapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridSerializableCollectionPredicateWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridSerializableCollectionPredicateWrapper.java
deleted file mode 100644
index 771da37..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridSerializableCollectionPredicateWrapper.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * 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 java.util.Iterator;
-import org.apache.ignite.internal.util.GridSerializableCollection;
-import org.apache.ignite.internal.util.lang.GridFunc;
-import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.lang.IgnitePredicate;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * Light-weight view on given collection with provided predicate.
- *
- * @param <T> Type of the collection.
- */
-public class GridSerializableCollectionPredicateWrapper<T> extends GridSerializableCollection<T> {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** */
- private final Collection<T> collection;
-
- /** */
- private final IgnitePredicate<? super T>[] predicates;
-
- /**
- * @param collection Input collection that serves as a base for the view.
- * @param predicates Optional predicates. If predicates are not provided - all elements will be in the view.
- */
- public GridSerializableCollectionPredicateWrapper(Collection<T> collection, IgnitePredicate<? super T>... predicates) {
- this.collection = collection;
- this.predicates = predicates;
- }
-
- /** {@inheritDoc} */
- @Override public boolean add(T e) {
- // Pass through (will fail for readonly).
- return GridFunc.isAll(e, predicates) && collection.add(e);
- }
-
- /** {@inheritDoc} */
- @NotNull @Override public Iterator<T> iterator() {
- return F.iterator0(collection, false, predicates);
- }
-
- /** {@inheritDoc} */
- @Override public int size() {
- return F.size(collection, predicates);
- }
-
- /** {@inheritDoc} */
- @Override public boolean isEmpty() {
- return F.isEmpty(predicates) ? collection.isEmpty() : !iterator().hasNext();
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(GridSerializableCollectionPredicateWrapper.class, this);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a3f845b0/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridSerializableCollectionWrapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridSerializableCollectionWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridSerializableCollectionWrapper.java
deleted file mode 100644
index cbabe9b..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridSerializableCollectionWrapper.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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 java.util.Iterator;
-import org.apache.ignite.internal.util.GridSerializableCollection;
-import org.apache.ignite.internal.util.lang.GridFunc;
-import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * Wrapper which iterable over the elements of the inner collections.
- *
- * @param <T> Type of the inner collections.
- */
-public class GridSerializableCollectionWrapper<T> extends GridSerializableCollection<T> {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** */
- private final Collection<? extends Collection<T>> collections;
-
- /**
- * @param collections Input collection of collections.
- */
- public GridSerializableCollectionWrapper(Collection<? extends Collection<T>> collections) {
- this.collections = collections;
- }
-
- /** {@inheritDoc} */
- @NotNull @Override public Iterator<T> iterator() {
- return GridFunc.flat((Iterable<? extends Iterable<T>>)collections);
- }
-
- /** {@inheritDoc} */
- @Override public int size() {
- return F.size(iterator());
- }
-
- /** {@inheritDoc} */
- @Override public boolean isEmpty() {
- return !iterator().hasNext();
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(GridSerializableCollectionWrapper.class, this);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a3f845b0/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridSerializableListReadOnlyWithTransformation.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridSerializableListReadOnlyWithTransformation.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridSerializableListReadOnlyWithTransformation.java
deleted file mode 100644
index a932e37..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridSerializableListReadOnlyWithTransformation.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * 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.Iterator;
-import java.util.List;
-import org.apache.ignite.internal.util.GridSerializableList;
-import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.lang.IgniteClosure;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * Light-weight view on given list with provided transformation.
- *
- * @param <T1> Element type after transformation.
- * @param <T2> Element type.
- */
-public class GridSerializableListReadOnlyWithTransformation<T1, T2> extends GridSerializableList<T1> {
- /** */
- private static final long serialVersionUID = 3126625219739967068L;
-
- /** */
- private final IgniteClosure<? super T2, T1> closure;
-
- /** */
- private final List<? extends T2> list;
-
- /**
- * @param closure closure Transformation closure.
- * @param list Input list that serves as a base for the view.
- */
- public GridSerializableListReadOnlyWithTransformation(IgniteClosure<? super T2, T1> closure,
- List<? extends T2> list) {
- this.closure = closure;
- this.list = list;
- }
-
- /** {@inheritDoc} */
- @Override public T1 get(int idx) {
- return closure.apply(list.get(idx));
- }
-
- /** {@inheritDoc} */
- @NotNull @Override public Iterator<T1> iterator() {
- return F.<T2, T1>iterator(list, closure, true);
- }
-
- /** {@inheritDoc} */
- @Override public int size() {
- return list.size();
- }
-
- /** {@inheritDoc} */
- @Override public boolean isEmpty() {
- return list.isEmpty();
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(GridSerializableListReadOnlyWithTransformation.class, this);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a3f845b0/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridSerializableMapPredicatesTransformerWrapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridSerializableMapPredicatesTransformerWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridSerializableMapPredicatesTransformerWrapper.java
deleted file mode 100644
index 9803ba8..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridSerializableMapPredicatesTransformerWrapper.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * 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.Iterator;
-import java.util.Map;
-import java.util.Set;
-import org.apache.ignite.internal.util.GridSerializableMap;
-import org.apache.ignite.internal.util.GridSerializableSet;
-import org.apache.ignite.internal.util.lang.GridFunc;
-import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.lang.IgniteClosure;
-import org.apache.ignite.lang.IgnitePredicate;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Light-weight view on given map with provided predicate and transformer.
- *
- * @param <K> Type of the key.
- * @param <V> Type of the input map value.
- * @param <V1> Type of the output map value.
- */
-public class GridSerializableMapPredicatesTransformerWrapper<K, V1, V> extends GridSerializableMap<K, V1> {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** */
- private final Map<K, V> map;
-
- /** */
- private final IgniteClosure<V, V1> transformer;
-
- /** */
- private final boolean hasPred;
-
- /** */
- private final IgnitePredicate<? super K>[] predicates;
-
- /** Entry predicate. */
- private IgnitePredicate<Entry<K, V>> ep;
-
- /**
- * @param map Input map that serves as a base for the view.
- * @param transformer Transformer for map value transformation.
- * @param predicates Optional predicates. If predicates are not provided - all will be in the view.
- */
- @SuppressWarnings({"unchecked"})
- public GridSerializableMapPredicatesTransformerWrapper(Map<K, V> map, IgniteClosure<V, V1> transformer,
- IgnitePredicate<? super K>... predicates) {
- this.map = map;
- this.transformer = transformer;
- this.hasPred = (predicates != null && predicates.length > 0);
- this.predicates = predicates;
- this.ep = new IgnitePredicateEvaluateEntryByKey(predicates);
- }
-
- /** {@inheritDoc} */
- @NotNull @Override public Set<Entry<K, V1>> entrySet() {
- return new GridSerializableSet<Entry<K, V1>>() {
- @NotNull
- @Override public Iterator<Entry<K, V1>> iterator() {
- return new Iterator<Entry<K, V1>>() {
- private Iterator<Entry<K, V>> it = GridFunc.iterator0(map.entrySet(), true, ep);
-
- @Override public boolean hasNext() {
- return it.hasNext();
- }
-
- @Override public Entry<K, V1> next() {
- final Entry<K, V> e = it.next();
-
- return new Entry<K, V1>() {
- @Override public K getKey() {
- return e.getKey();
- }
-
- @Override public V1 getValue() {
- return transformer.apply(e.getValue());
- }
-
- @Override public V1 setValue(V1 val) {
- throw new UnsupportedOperationException("Put is not supported for readonly map view.");
- }
- };
- }
-
- @Override public void remove() {
- throw new UnsupportedOperationException("Remove is not support for readonly map view.");
- }
- };
- }
-
- @Override public int size() {
- return hasPred ? F.size(map.keySet(), predicates) : map.size();
- }
-
- @SuppressWarnings({"unchecked"})
- @Override public boolean remove(Object o) {
- throw new UnsupportedOperationException("Remove is not support for readonly map view.");
- }
-
- @SuppressWarnings({"unchecked"})
- @Override public boolean contains(Object o) {
- return F.isAll((Entry<K, V>)o, ep) && map.entrySet().contains(o);
- }
-
- @Override public boolean isEmpty() {
- return hasPred ? !iterator().hasNext() : map.isEmpty();
- }
- };
- }
-
- /** {@inheritDoc} */
- @Override public boolean isEmpty() {
- return hasPred ? entrySet().isEmpty() : map.isEmpty();
- }
-
- /** {@inheritDoc} */
- @SuppressWarnings({"unchecked"})
- @Nullable @Override public V1 get(Object key) {
- if (GridFunc.isAll((K)key, predicates)) {
- V v = map.get(key);
-
- if (v != null)
- return transformer.apply(v);
- }
-
- return null;
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public V1 put(K key, V1 val) {
- throw new UnsupportedOperationException("Put is not supported for readonly map view.");
- }
-
- /** {@inheritDoc} */
- @Override public V1 remove(Object key) {
- throw new UnsupportedOperationException("Remove is not supported for readonly map view.");
- }
-
- /** {@inheritDoc} */
- @SuppressWarnings({"unchecked"})
- @Override public boolean containsKey(Object key) {
- return GridFunc.isAll((K)key, predicates) && map.containsKey(key);
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(GridSerializableMapPredicatesTransformerWrapper.class, this);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a3f845b0/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridSerializableMapPredicatesWrapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridSerializableMapPredicatesWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridSerializableMapPredicatesWrapper.java
deleted file mode 100644
index 3528ae8..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridSerializableMapPredicatesWrapper.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * 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.Iterator;
-import java.util.Map;
-import java.util.Set;
-import org.apache.ignite.internal.util.GridSerializableMap;
-import org.apache.ignite.internal.util.GridSerializableSet;
-import org.apache.ignite.internal.util.lang.GridFunc;
-import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.lang.IgnitePredicate;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Light-weight view on given map with provided predicate.
- *
- * @param <K> Type of the key.
- * @param <V> Type of the value.
- */
-public class GridSerializableMapPredicatesWrapper<K, V> extends GridSerializableMap<K, V> {
- /** */
- private static final long serialVersionUID = 5531745605372387948L;
-
- /** */
- private final Map<K, V> map;
-
- /** */
- private final IgnitePredicate<? super K>[] predicates;
-
- /** Entry predicate. */
- private IgnitePredicate<Entry<K, V>> entryPredicate;
-
- /**
- * @param map Input map that serves as a base for the view.
- * @param predicates Optional predicates. If predicates are not provided - all will be in the view.
- */
- @SuppressWarnings({"unchecked"})
- public GridSerializableMapPredicatesWrapper(Map<K, V> map, IgnitePredicate<? super K>... predicates) {
- this.map = map;
- this.predicates = predicates;
- this.entryPredicate = new IgnitePredicateEvaluateEntryByKey(predicates);
- }
-
- /** {@inheritDoc} */
- @NotNull @Override public Set<Entry<K, V>> entrySet() {
- return new GridSerializableSet<Entry<K, V>>() {
- @NotNull
- @Override public Iterator<Entry<K, V>> iterator() {
- return GridFunc.iterator0(map.entrySet(), false, entryPredicate);
- }
-
- @Override public int size() {
- return F.size(map.keySet(), predicates);
- }
-
- @SuppressWarnings({"unchecked"})
- @Override public boolean remove(Object o) {
- return F.isAll((Entry<K, V>)o, entryPredicate) && map.entrySet().remove(o);
- }
-
- @SuppressWarnings({"unchecked"})
- @Override public boolean contains(Object o) {
- return F.isAll((Entry<K, V>)o, entryPredicate) && map.entrySet().contains(o);
- }
-
- @Override public boolean isEmpty() {
- return !iterator().hasNext();
- }
- };
- }
-
- /** {@inheritDoc} */
- @Override public boolean isEmpty() {
- return entrySet().isEmpty();
- }
-
- /** {@inheritDoc} */
- @SuppressWarnings({"unchecked"})
- @Nullable @Override public V get(Object key) {
- return GridFunc.isAll((K)key, predicates) ? map.get(key) : null;
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public V put(K key, V val) {
- V oldVal = get(key);
-
- if (GridFunc.isAll(key, predicates))
- map.put(key, val);
-
- return oldVal;
- }
-
- /** {@inheritDoc} */
- @SuppressWarnings({"unchecked"})
- @Override public boolean containsKey(Object key) {
- return GridFunc.isAll((K)key, predicates) && map.containsKey(key);
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(GridSerializableMapPredicatesWrapper.class, this);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a3f845b0/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridSerializableMapReadOnlyClosurePredicateWrapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridSerializableMapReadOnlyClosurePredicateWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridSerializableMapReadOnlyClosurePredicateWrapper.java
deleted file mode 100644
index 2782b93..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridSerializableMapReadOnlyClosurePredicateWrapper.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * 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.Iterator;
-import java.util.Map;
-import java.util.Set;
-import org.apache.ignite.internal.util.GridSerializableMap;
-import org.apache.ignite.internal.util.GridSerializableSet;
-import org.apache.ignite.internal.util.lang.GridFunc;
-import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.lang.IgniteBiClosure;
-import org.apache.ignite.lang.IgnitePredicate;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Light-weight view on given map with provided predicate and transformer.
- *
- * @param <K> Type of the key.
- * @param <V> Type of the input map value.
- * @param <V1> Type of the output map value.
- */
-public class GridSerializableMapReadOnlyClosurePredicateWrapper<K, V, V1> extends GridSerializableMap<K, V1> {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** */
- private final Map<K, V> map;
-
- /** */
- private final IgniteBiClosure<K, V, V1> transformer;
-
- /** */
- private final IgnitePredicate<? super K>[] predicates;
-
- /** Entry predicate. */
- private IgnitePredicate<Entry<K, V>> entryPredicate;
-
- /**
- * @param map Input map that serves as a base for the view.
- * @param transformer Transformer for map value transformation.
- * @param predicates Optional predicates. If predicates are not provided - all will be in the view.
- */
- @SuppressWarnings({"unchecked"})
- public GridSerializableMapReadOnlyClosurePredicateWrapper(Map<K, V> map, IgniteBiClosure<K, V, V1> transformer,
- IgnitePredicate<? super K>... predicates) {
- this.map = map;
- this.transformer = transformer;
- this.predicates = predicates;
- entryPredicate = new IgnitePredicateEvaluateEntryByKey(predicates);
- }
-
- /** {@inheritDoc} */
- @NotNull @Override public Set<Entry<K, V1>> entrySet() {
- return new GridSerializableSet<Entry<K, V1>>() {
- @NotNull
- @Override public Iterator<Entry<K, V1>> iterator() {
- return new Iterator<Entry<K, V1>>() {
- private Iterator<Entry<K, V>> it = GridFunc.iterator0(map.entrySet(), true, entryPredicate);
-
- @Override public boolean hasNext() {
- return it.hasNext();
- }
-
- @Override public Entry<K, V1> next() {
- final Entry<K, V> e = it.next();
-
- return new Entry<K, V1>() {
- @Override public K getKey() {
- return e.getKey();
- }
-
- @Override public V1 getValue() {
- return transformer.apply(e.getKey(), e.getValue());
- }
-
- @Override public V1 setValue(V1 val) {
- throw new UnsupportedOperationException(
- "Put is not supported for readonly map view.");
- }
- };
- }
-
- @Override public void remove() {
- throw new UnsupportedOperationException("Remove is not support for readonly map view.");
- }
- };
- }
-
- @Override public int size() {
- return F.size(map.keySet(), predicates);
- }
-
- @SuppressWarnings({"unchecked"})
- @Override public boolean remove(Object o) {
- throw new UnsupportedOperationException("Remove is not support for readonly map view.");
- }
-
- @SuppressWarnings({"unchecked"})
- @Override public boolean contains(Object o) {
- return F.isAll((Entry<K, V>)o, entryPredicate) && map.entrySet().contains(o);
- }
-
- @Override public boolean isEmpty() {
- return !iterator().hasNext();
- }
- };
- }
-
- /** {@inheritDoc} */
- @Override public boolean isEmpty() {
- return entrySet().isEmpty();
- }
-
- /** {@inheritDoc} */
- @SuppressWarnings({"unchecked"})
- @Nullable @Override public V1 get(Object key) {
- if (GridFunc.isAll((K)key, predicates)) {
- V v = map.get(key);
-
- if (v != null)
- return transformer.apply((K)key, v);
- }
-
- return null;
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public V1 put(K key, V1 val) {
- throw new UnsupportedOperationException("Put is not supported for readonly map view.");
- }
-
- /** {@inheritDoc} */
- @Override public V1 remove(Object key) {
- throw new UnsupportedOperationException("Remove is not supported for readonly map view.");
- }
-
- /** {@inheritDoc} */
- @SuppressWarnings({"unchecked"})
- @Override public boolean containsKey(Object key) {
- return GridFunc.isAll((K)key, predicates) && map.containsKey(key);
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(GridSerializableMapReadOnlyClosurePredicateWrapper.class, this);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a3f845b0/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridSerializableMapReadOnlyPredicateWrapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridSerializableMapReadOnlyPredicateWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridSerializableMapReadOnlyPredicateWrapper.java
deleted file mode 100644
index 10c36ef..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridSerializableMapReadOnlyPredicateWrapper.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * 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.Iterator;
-import java.util.Set;
-import org.apache.ignite.internal.util.GridSerializableMap;
-import org.apache.ignite.internal.util.GridSerializableSet;
-import org.apache.ignite.internal.util.lang.GridFunc;
-import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.lang.IgniteClosure;
-import org.apache.ignite.lang.IgnitePredicate;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Light-weight view on given map with provided predicates and mapping.
- *
- * @param <K> Key type.
- * @param <V> Value type.
- */
-public class GridSerializableMapReadOnlyPredicateWrapper<K, V> extends GridSerializableMap<K, V> {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** */
- private final Set<K> set;
-
- /** */
- private final IgniteClosure<? super K, V> mappingClosure;
-
- /** */
- private final IgnitePredicate<? super K>[] predicates;
-
- /** Entry predicate. */
- private IgnitePredicate<K> entryPredicate;
-
- /**
- * @param set Input collection.
- * @param mappingClosure Mapping closure, that maps key to value.
- * @param predicates Optional predicates to filter input collection. If predicates are not provided - all elements
- * will be in
- */
- @SuppressWarnings({"unchecked"})
- public GridSerializableMapReadOnlyPredicateWrapper(Set<K> set, IgniteClosure<? super K, V> mappingClosure,
- IgnitePredicate<? super K>... predicates) {
- this.set = set;
- this.mappingClosure = mappingClosure;
- this.predicates = predicates;
- this.entryPredicate = new IgnitePredicateIsAll(predicates);
- }
-
- /** {@inheritDoc} */
- @NotNull @Override public Set<Entry<K, V>> entrySet() {
- return new GridSerializableSet<Entry<K, V>>() {
- @NotNull @Override public Iterator<Entry<K, V>> iterator() {
- return new Iterator<Entry<K, V>>() {
-
- private Iterator<K> it = GridFunc.iterator0(set, true, entryPredicate);
-
- @Override public boolean hasNext() {
- return it.hasNext();
- }
-
- @Override public Entry<K, V> next() {
- final K e = it.next();
-
- return new Entry<K, V>() {
- @Override public K getKey() {
- return e;
- }
-
- @Override public V getValue() {
- return mappingClosure.apply(e);
- }
-
- @Override public V setValue(V val) {
- throw new UnsupportedOperationException(
- "Put is not supported for readonly collection view.");
- }
- };
- }
-
- @Override public void remove() {
- throw new UnsupportedOperationException(
- "Remove is not support for readonly collection view.");
- }
- };
- }
-
- @Override public int size() {
- return F.size(set, predicates);
- }
-
- @Override public boolean remove(Object o) {
- throw new UnsupportedOperationException("Remove is not support for readonly collection view.");
- }
-
- @Override public boolean isEmpty() {
- return !iterator().hasNext();
- }
- };
- }
-
- /** {@inheritDoc} */
- @Override public boolean isEmpty() {
- return entrySet().isEmpty();
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public V get(Object key) {
- if (containsKey(key))
- return mappingClosure.apply((K)key);
-
- return null;
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public V put(K key, V val) {
- throw new UnsupportedOperationException("Put is not supported for readonly collection view.");
- }
-
- /** {@inheritDoc} */
- @Override public V remove(Object key) {
- throw new UnsupportedOperationException("Remove is not supported for readonly collection view.");
- }
-
- /** {@inheritDoc} */
- @Override public boolean containsKey(Object key) {
- return GridFunc.isAll((K)key, predicates) && set.contains(key);
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(GridSerializableMapReadOnlyPredicateWrapper.class, this);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a3f845b0/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridSerializableReadOnlyCollectionPredicateWrapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridSerializableReadOnlyCollectionPredicateWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridSerializableReadOnlyCollectionPredicateWrapper.java
deleted file mode 100644
index cce95a6..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridSerializableReadOnlyCollectionPredicateWrapper.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * 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 java.util.Iterator;
-import org.apache.ignite.internal.util.GridSerializableCollection;
-import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.lang.IgniteClosure;
-import org.apache.ignite.lang.IgnitePredicate;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * Light-weight view on given collection with provided predicate.
- *
- * @param <T1> Element type after transformation.
- * @param <T2> Element type.
- */
-public class GridSerializableReadOnlyCollectionPredicateWrapper<T1, T2> extends GridSerializableCollection<T1> {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** */
- private final Collection<? extends T2> collection;
-
- /** */
- private final IgniteClosure<? super T2, T1> transformer;
-
- /** */
- private final IgnitePredicate<? super T2>[] predicates;
-
- /**
- * @param collection Input collection that serves as a base for the view.
- * @param transformer Transformation closure.
- * @param predicates Optional predicated. If predicates are not provided - all elements will be in the view.
- */
- public GridSerializableReadOnlyCollectionPredicateWrapper(Collection<? extends T2> collection,
- IgniteClosure<? super T2, T1> transformer, IgnitePredicate<? super T2>... predicates) {
- this.collection = collection;
- this.transformer = transformer;
- this.predicates = predicates;
- }
-
- /** {@inheritDoc} */
- @NotNull @Override public Iterator<T1> iterator() {
- return F.<T2, T1>iterator(collection, transformer, true, predicates);
- }
-
- /** {@inheritDoc} */
- @Override public int size() {
- return F.isEmpty(predicates) ? collection.size() : F.size(iterator());
- }
-
- /** {@inheritDoc} */
- @Override public boolean isEmpty() {
- return F.isEmpty(predicates) ? collection.isEmpty() : !iterator().hasNext();
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(GridSerializableReadOnlyCollectionPredicateWrapper.class, this);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a3f845b0/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridSerializableReadOnlyCollectionWrapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridSerializableReadOnlyCollectionWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridSerializableReadOnlyCollectionWrapper.java
deleted file mode 100644
index 3bec907..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridSerializableReadOnlyCollectionWrapper.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * 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 java.util.Iterator;
-import org.apache.ignite.internal.util.GridSerializableCollection;
-import org.apache.ignite.internal.util.GridSerializableIterator;
-import org.apache.ignite.internal.util.lang.GridFunc;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Collection wrapper.
- * A read-only view will be created over the element and given
- * collections and no copying will happen.
- *
- * @param <T> Element type.
- */
-public class GridSerializableReadOnlyCollectionWrapper<T> extends GridSerializableCollection<T> {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** Collection. */
- private final Collection<T> collection;
-
- /** First element in the collection. */
- private final T firstElement;
-
- /**
- * @param collection Collection to wrap.
- * @param firstElement First element.
- */
- public GridSerializableReadOnlyCollectionWrapper(@NotNull Collection<T> collection, @NotNull T firstElement) {
- this.collection = collection;
- this.firstElement = firstElement;
- }
-
- /** {@inheritDoc} */
- @NotNull
- @Override public Iterator<T> iterator() {
- return new GridSerializableIterator<T>() {
- private Iterator<T> it;
-
- @Override public boolean hasNext() {
- return it == null || it.hasNext();
- }
-
- @Nullable @Override public T next() {
- if (it == null) {
- it = collection.iterator();
-
- return firstElement;
- }
-
- return it.next();
- }
-
- @Override public void remove() {
- throw new UnsupportedOperationException();
- }
- };
- }
-
- /** {@inheritDoc} */
- @Override public int size() {
- return collection.size() + 1;
- }
-
- /** {@inheritDoc} */
- @Override public boolean equals(Object obj) {
- return obj instanceof Collection && GridFunc.eqNotOrdered(this, (Collection)obj);
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(GridSerializableReadOnlyCollectionWrapper.class, this);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a3f845b0/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridSerializableReadOnlyTwoCollectionsWrapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridSerializableReadOnlyTwoCollectionsWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridSerializableReadOnlyTwoCollectionsWrapper.java
deleted file mode 100644
index 5747d2c..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/GridSerializableReadOnlyTwoCollectionsWrapper.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * 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 java.util.Iterator;
-import org.apache.ignite.internal.util.GridSerializableCollection;
-import org.apache.ignite.internal.util.GridSerializableIterator;
-import org.apache.ignite.internal.util.lang.GridFunc;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * Collections wrapper.
- * A read-only view will be created over the element and given
- * collections and no copying will happen.
- *
- * @param <T> Element type.
- */
-public class GridSerializableReadOnlyTwoCollectionsWrapper<T> extends GridSerializableCollection<T> {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** First collection. */
- private final Collection<T> c1;
-
- /** SecondCollection. */
- private final Collection<T> c2;
-
- /**
- * @param c1 First collection.
- * @param c2 SecondCollection.
- */
- public GridSerializableReadOnlyTwoCollectionsWrapper(Collection<T> c1, Collection<T> c2) {
- this.c1 = c1;
- this.c2 = c2;
- }
-
- /** {@inheritDoc} */
- @NotNull
- @Override public Iterator<T> iterator() {
- return new GridSerializableIterator<T>() {
- private Iterator<T> it1 = c1.iterator();
- private Iterator<T> it2 = c2.iterator();
-
- @Override public boolean hasNext() {
- if (it1 != null)
- if (!it1.hasNext())
- it1 = null;
- else
- return true;
-
- return it2.hasNext();
- }
-
- @Override public T next() {
- return it1 != null ? it1.next() : it2.next();
- }
-
- @Override public void remove() {
- throw new UnsupportedOperationException();
- }
- };
- }
-
- /** {@inheritDoc} */
- @Override public boolean contains(Object o) {
- return c1.contains(o) || c2.contains(o);
- }
-
- /** {@inheritDoc} */
- @Override public int size() {
- return c1.size() + c2.size();
- }
-
- /** {@inheritDoc} */
- @Override public boolean equals(Object obj) {
- return obj instanceof Collection && GridFunc.eqNotOrdered(this, (Collection<?>)obj);
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(GridSerializableReadOnlyTwoCollectionsWrapper.class, this);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a3f845b0/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/HasEqualIdPredicate.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/HasEqualIdPredicate.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/HasEqualIdPredicate.java
new file mode 100644
index 0000000..9f5f927
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/HasEqualIdPredicate.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 HasEqualIdPredicate<T extends ClusterNode> implements IgnitePredicate<T> {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ private final UUID locNodeId;
+
+ /**
+ * @param locNodeId Id for check.
+ */
+ public HasEqualIdPredicate(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(HasEqualIdPredicate.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a3f845b0/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/HasNotEqualIdPredicate.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/HasNotEqualIdPredicate.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/HasNotEqualIdPredicate.java
new file mode 100644
index 0000000..e467749
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/HasNotEqualIdPredicate.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 HasNotEqualIdPredicate<T extends ClusterNode> implements IgnitePredicate<T> {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ private final UUID locNodeId;
+
+ /**
+ * @param locNodeId Id for check.
+ */
+ public HasNotEqualIdPredicate(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(HasNotEqualIdPredicate.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a3f845b0/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IdentityClosure.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IdentityClosure.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IdentityClosure.java
new file mode 100644
index 0000000..a053a3f
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IdentityClosure.java
@@ -0,0 +1,39 @@
+/*
+ * 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.IgniteClosure;
+
+/**
+ * Identity closure.
+ */
+public class IdentityClosure implements IgniteClosure {
+ /** */
+ private static final long serialVersionUID = -6338573080046225172L;
+
+ /** {@inheritDoc} */
+ @Override public Object apply(Object o) {
+ return o;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(IdentityClosure.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a3f845b0/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgniteCallableArrayListFactory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgniteCallableArrayListFactory.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgniteCallableArrayListFactory.java
deleted file mode 100644
index 017397d..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgniteCallableArrayListFactory.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.ArrayList;
-import java.util.List;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.lang.IgniteCallable;
-
-/**
- * Array list factory.
- */
-public class IgniteCallableArrayListFactory implements IgniteCallable<List> {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** {@inheritDoc} */
- @Override public ArrayList call() {
- return new ArrayList();
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(IgniteCallableArrayListFactory.class, this);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a3f845b0/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgniteCallableAtomicBooleanFactory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgniteCallableAtomicBooleanFactory.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgniteCallableAtomicBooleanFactory.java
deleted file mode 100644
index a935471..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgniteCallableAtomicBooleanFactory.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.AtomicBoolean;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.lang.IgniteCallable;
-
-/**
- * Atomic boolean factory.
- */
-public class IgniteCallableAtomicBooleanFactory implements IgniteCallable<AtomicBoolean> {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** {@inheritDoc} */
- @Override public AtomicBoolean call() {
- return new AtomicBoolean();
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(IgniteCallableAtomicBooleanFactory.class, this);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a3f845b0/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgniteCallableAtomicIntegerFactory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgniteCallableAtomicIntegerFactory.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgniteCallableAtomicIntegerFactory.java
deleted file mode 100644
index 9a8df06..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgniteCallableAtomicIntegerFactory.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.IgniteCallable;
-
-/**
- * Atomic integer factory.
- */
-public class IgniteCallableAtomicIntegerFactory implements IgniteCallable<AtomicInteger> {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** {@inheritDoc} */
- @Override public AtomicInteger call() {
- return new AtomicInteger(0);
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(IgniteCallableAtomicIntegerFactory.class, this);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a3f845b0/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgniteCallableAtomicLongFactory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgniteCallableAtomicLongFactory.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgniteCallableAtomicLongFactory.java
deleted file mode 100644
index 7499c29..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgniteCallableAtomicLongFactory.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.IgniteCallable;
-
-/**
- * Atomic long factory.
- */
-public class IgniteCallableAtomicLongFactory implements IgniteCallable<AtomicLong> {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** {@inheritDoc} */
- @Override public AtomicLong call() {
- return new AtomicLong(0);
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(IgniteCallableAtomicLongFactory.class, this);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a3f845b0/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgniteCallableAtomicReferenceFactory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgniteCallableAtomicReferenceFactory.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgniteCallableAtomicReferenceFactory.java
deleted file mode 100644
index ed0ff58..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/IgniteCallableAtomicReferenceFactory.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.AtomicReference;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.lang.IgniteCallable;
-
-/**
- * Atomic reference factory.
- */
-public class IgniteCallableAtomicReferenceFactory implements IgniteCallable<AtomicReference> {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** {@inheritDoc} */
- @Override public AtomicReference call() {
- return new AtomicReference();
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(IgniteCallableAtomicReferenceFactory.class, this);
- }
-}