You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ag...@apache.org on 2017/04/13 13:30:52 UTC
[05/21] ignite git commit: ignite-3682: method which are used in
scalar-module was returned
ignite-3682: method which are used in scalar-module was returned
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/7e1d5831
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/7e1d5831
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/7e1d5831
Branch: refs/heads/ignite-3477-master
Commit: 7e1d58314e1e99490565ecb02193ddc2bcedfaf3
Parents: b2441db
Author: daradurvs <da...@gmail.com>
Authored: Tue Apr 4 21:06:40 2017 +0300
Committer: agura <ag...@apache.org>
Committed: Mon Apr 10 19:39:06 2017 +0300
----------------------------------------------------------------------
.../ignite/internal/util/lang/GridFunc.java | 14 +++++-
.../lang/gridfunc/RunnableWrapperClosure.java | 51 ++++++++++++++++++++
2 files changed, 64 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/7e1d5831/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
index 71ff014..c93f077 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
@@ -53,8 +53,8 @@ import org.apache.ignite.internal.util.lang.gridfunc.AtomicBooleanFactoryCallabl
import org.apache.ignite.internal.util.lang.gridfunc.AtomicIntegerFactoryCallable;
import org.apache.ignite.internal.util.lang.gridfunc.AtomicLongFactoryCallable;
import org.apache.ignite.internal.util.lang.gridfunc.AtomicReferenceFactoryCallable;
-import org.apache.ignite.internal.util.lang.gridfunc.CacheEntryGetValueClosure;
import org.apache.ignite.internal.util.lang.gridfunc.CacheEntryGetKeyClosure;
+import org.apache.ignite.internal.util.lang.gridfunc.CacheEntryGetValueClosure;
import org.apache.ignite.internal.util.lang.gridfunc.CacheEntryHasPeekPredicate;
import org.apache.ignite.internal.util.lang.gridfunc.ClusterNodeGetId8Closure;
import org.apache.ignite.internal.util.lang.gridfunc.ClusterNodeGetIdClosure;
@@ -91,6 +91,7 @@ import org.apache.ignite.internal.util.lang.gridfunc.PredicateMapView;
import org.apache.ignite.internal.util.lang.gridfunc.PredicateSetView;
import org.apache.ignite.internal.util.lang.gridfunc.ReadOnlyCollectionView;
import org.apache.ignite.internal.util.lang.gridfunc.ReadOnlyCollectionView2X;
+import org.apache.ignite.internal.util.lang.gridfunc.RunnableWrapperClosure;
import org.apache.ignite.internal.util.lang.gridfunc.SetFactoryCallable;
import org.apache.ignite.internal.util.lang.gridfunc.StringConcatReducer;
import org.apache.ignite.internal.util.lang.gridfunc.ToStringClosure;
@@ -970,6 +971,17 @@ public class GridFunc {
}
/**
+ * Converts given runnable to an absolute closure.
+ *
+ * @param r Runnable to convert to closure. If {@code null} - no-op closure is returned.
+ * @return Closure that wraps given runnable. Note that wrapping closure always returns {@code null}.
+ */
+ @Deprecated
+ public static GridAbsClosure as(@Nullable final Runnable r) {
+ return new RunnableWrapperClosure(r);
+ }
+
+ /**
* Gets size of the given collection with provided optional predicates.
*
* @param c Collection to size.
http://git-wip-us.apache.org/repos/asf/ignite/blob/7e1d5831/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/RunnableWrapperClosure.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/RunnableWrapperClosure.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/RunnableWrapperClosure.java
new file mode 100644
index 0000000..8db1864
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/RunnableWrapperClosure.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.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 RunnableWrapperClosure 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 RunnableWrapperClosure(Runnable r) {
+ this.r = r;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void apply() {
+ if (r != null)
+ r.run();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(RunnableWrapperClosure.class, this);
+ }
+}