You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by cs...@apache.org on 2017/10/10 15:52:23 UTC
svn commit: r1811731 - in
/aries/trunk/component-dsl/component-dsl/src/main/java/org/apache/aries/osgi/functional:
OSGi.java internal/IgnoreImpl.java
Author: csierra
Date: Tue Oct 10 15:52:23 2017
New Revision: 1811731
URL: http://svn.apache.org/viewvc?rev=1811731&view=rev
Log:
[Component-DSL] Reimplement foreach with effects
Added:
aries/trunk/component-dsl/component-dsl/src/main/java/org/apache/aries/osgi/functional/internal/IgnoreImpl.java
Modified:
aries/trunk/component-dsl/component-dsl/src/main/java/org/apache/aries/osgi/functional/OSGi.java
Modified: aries/trunk/component-dsl/component-dsl/src/main/java/org/apache/aries/osgi/functional/OSGi.java
URL: http://svn.apache.org/viewvc/aries/trunk/component-dsl/component-dsl/src/main/java/org/apache/aries/osgi/functional/OSGi.java?rev=1811731&r1=1811730&r2=1811731&view=diff
==============================================================================
--- aries/trunk/component-dsl/component-dsl/src/main/java/org/apache/aries/osgi/functional/OSGi.java (original)
+++ aries/trunk/component-dsl/component-dsl/src/main/java/org/apache/aries/osgi/functional/OSGi.java Tue Oct 10 15:52:23 2017
@@ -29,6 +29,7 @@ import org.apache.aries.osgi.functional.
import org.apache.aries.osgi.functional.internal.ConfigurationOSGiImpl;
import org.apache.aries.osgi.functional.internal.ConfigurationsOSGiImpl;
import org.apache.aries.osgi.functional.internal.DistributeOSGi;
+import org.apache.aries.osgi.functional.internal.IgnoreImpl;
import org.apache.aries.osgi.functional.internal.JustOSGiImpl;
import org.apache.aries.osgi.functional.internal.NothingOSGiImpl;
import org.apache.aries.osgi.functional.internal.OnCloseOSGiImpl;
@@ -56,6 +57,13 @@ import java.util.function.Supplier;
public interface OSGi<T> extends OSGiRunnable<T> {
Runnable NOOP = () -> {};
+ OSGi<T> effects(
+ Consumer<? super T> onAdded, Consumer<? super T> onRemoved);
+
+ static OSGi<Void> ignore(OSGi<?> program) {
+ return new IgnoreImpl(program);
+ }
+
<S> OSGi<S> map(Function<? super T, ? extends S> function);
<S> OSGi<S> flatMap(Function<? super T, OSGi<? extends S>> fun);
Added: aries/trunk/component-dsl/component-dsl/src/main/java/org/apache/aries/osgi/functional/internal/IgnoreImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/component-dsl/component-dsl/src/main/java/org/apache/aries/osgi/functional/internal/IgnoreImpl.java?rev=1811731&view=auto
==============================================================================
--- aries/trunk/component-dsl/component-dsl/src/main/java/org/apache/aries/osgi/functional/internal/IgnoreImpl.java (added)
+++ aries/trunk/component-dsl/component-dsl/src/main/java/org/apache/aries/osgi/functional/internal/IgnoreImpl.java Tue Oct 10 15:52:23 2017
@@ -0,0 +1,33 @@
+/*
+ * 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.aries.osgi.functional.internal;
+
+import org.apache.aries.osgi.functional.OSGi;
+
+/**
+ * @author Carlos Sierra Andrés
+ */
+public class IgnoreImpl extends OSGiImpl<Void> {
+
+ public IgnoreImpl(OSGi<?> program) {
+
+ super((bundleContext, op) ->
+ ((OSGiImpl<?>) program)._operation.run(bundleContext, t -> {}));
+ }
+
+}