You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by da...@apache.org on 2016/10/27 16:37:17 UTC
svn commit: r1766855 - in /felix/trunk/converter/converter: ./
src/main/java/org/apache/felix/converter/impl/
src/main/java/org/osgi/util/converter/ src/main/java/org/osgi/util/function/
Author: davidb
Date: Thu Oct 27 16:37:16 2016
New Revision: 1766855
URL: http://svn.apache.org/viewvc?rev=1766855&view=rev
Log:
Felix Converter - take Function from org.osgi.util.function (latest version)
Added:
felix/trunk/converter/converter/src/main/java/org/osgi/util/function/
felix/trunk/converter/converter/src/main/java/org/osgi/util/function/Callback.java
felix/trunk/converter/converter/src/main/java/org/osgi/util/function/Function.java
felix/trunk/converter/converter/src/main/java/org/osgi/util/function/Predicate.java
felix/trunk/converter/converter/src/main/java/org/osgi/util/function/package-info.java
Removed:
felix/trunk/converter/converter/src/main/java/org/osgi/util/converter/Function.java
Modified:
felix/trunk/converter/converter/pom.xml
felix/trunk/converter/converter/src/main/java/org/apache/felix/converter/impl/AdapterImpl.java
felix/trunk/converter/converter/src/main/java/org/apache/felix/converter/impl/ConverterBuilderImpl.java
felix/trunk/converter/converter/src/main/java/org/osgi/util/converter/ConverterBuilder.java
felix/trunk/converter/converter/src/main/java/org/osgi/util/converter/Converting.java
Modified: felix/trunk/converter/converter/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/converter/converter/pom.xml?rev=1766855&r1=1766854&r2=1766855&view=diff
==============================================================================
--- felix/trunk/converter/converter/pom.xml (original)
+++ felix/trunk/converter/converter/pom.xml Thu Oct 27 16:37:16 2016
@@ -66,7 +66,7 @@
<configuration>
<instructions>
<Private-Package>org.apache.felix.converter.*</Private-Package>
- <Export-Package>org.osgi.util.converter</Export-Package>
+ <Export-Package>org.osgi.util.converter,org.osgi.util.function</Export-Package>
<Import-Package>org.osgi.util.converter, *</Import-Package>
</instructions>
</configuration>
@@ -90,6 +90,12 @@
<dependencies>
<dependency>
<groupId>org.osgi</groupId>
+ <artifactId>org.osgi.util.function</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.osgi</groupId>
<artifactId>osgi.annotation</artifactId>
<version>6.0.1</version>
<scope>provided</scope>
Modified: felix/trunk/converter/converter/src/main/java/org/apache/felix/converter/impl/AdapterImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/converter/src/main/java/org/apache/felix/converter/impl/AdapterImpl.java?rev=1766855&r1=1766854&r2=1766855&view=diff
==============================================================================
--- felix/trunk/converter/converter/src/main/java/org/apache/felix/converter/impl/AdapterImpl.java (original)
+++ felix/trunk/converter/converter/src/main/java/org/apache/felix/converter/impl/AdapterImpl.java Thu Oct 27 16:37:16 2016
@@ -33,9 +33,9 @@ import org.osgi.util.converter.ConvertFu
import org.osgi.util.converter.Converter;
import org.osgi.util.converter.ConverterBuilder;
import org.osgi.util.converter.Converting;
-import org.osgi.util.converter.Function;
import org.osgi.util.converter.Rule;
import org.osgi.util.converter.TypeReference;
+import org.osgi.util.function.Function;
public class AdapterImpl implements InternalConverter {
private final InternalConverter delegate;
@@ -233,7 +233,7 @@ public class AdapterImpl implements Inte
@Override
public T convert(F obj, Type targetType) throws Exception {
- return function.convert(obj);
+ return function.apply(obj);
}
}
}
Modified: felix/trunk/converter/converter/src/main/java/org/apache/felix/converter/impl/ConverterBuilderImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/converter/src/main/java/org/apache/felix/converter/impl/ConverterBuilderImpl.java?rev=1766855&r1=1766854&r2=1766855&view=diff
==============================================================================
--- felix/trunk/converter/converter/src/main/java/org/apache/felix/converter/impl/ConverterBuilderImpl.java (original)
+++ felix/trunk/converter/converter/src/main/java/org/apache/felix/converter/impl/ConverterBuilderImpl.java Thu Oct 27 16:37:16 2016
@@ -22,9 +22,9 @@ import java.util.List;
import org.apache.felix.converter.impl.AdapterImpl.ConvertFunctionImpl;
import org.osgi.util.converter.ConverterBuilder;
-import org.osgi.util.converter.Function;
import org.osgi.util.converter.Rule;
import org.osgi.util.converter.TypeReference;
+import org.osgi.util.function.Function;
public class ConverterBuilderImpl implements ConverterBuilder {
private final InternalConverter adapter;
Modified: felix/trunk/converter/converter/src/main/java/org/osgi/util/converter/ConverterBuilder.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/converter/src/main/java/org/osgi/util/converter/ConverterBuilder.java?rev=1766855&r1=1766854&r2=1766855&view=diff
==============================================================================
--- felix/trunk/converter/converter/src/main/java/org/osgi/util/converter/ConverterBuilder.java (original)
+++ felix/trunk/converter/converter/src/main/java/org/osgi/util/converter/ConverterBuilder.java Thu Oct 27 16:37:16 2016
@@ -18,6 +18,7 @@ package org.osgi.util.converter;
import java.lang.reflect.Type;
import org.osgi.annotation.versioning.ProviderType;
+import org.osgi.util.function.Function;
/**
* A builder to create a new converter with modified behaviour based on an
Modified: felix/trunk/converter/converter/src/main/java/org/osgi/util/converter/Converting.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/converter/src/main/java/org/osgi/util/converter/Converting.java?rev=1766855&r1=1766854&r2=1766855&view=diff
==============================================================================
--- felix/trunk/converter/converter/src/main/java/org/osgi/util/converter/Converting.java (original)
+++ felix/trunk/converter/converter/src/main/java/org/osgi/util/converter/Converting.java Thu Oct 27 16:37:16 2016
@@ -45,7 +45,8 @@ public interface Converting {
* Always return a fully populated copy of the object, however if the object
* is an immutable built-in scalar such as String or Long, then a copy is not
* needed. By default a wrapped object is returned by the converter if possible.
- * @return
+ * @return The current {@code Converting} object so that additional calls
+ * can be chained.
*/
Converting copy();
Added: felix/trunk/converter/converter/src/main/java/org/osgi/util/function/Callback.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/converter/src/main/java/org/osgi/util/function/Callback.java?rev=1766855&view=auto
==============================================================================
--- felix/trunk/converter/converter/src/main/java/org/osgi/util/function/Callback.java (added)
+++ felix/trunk/converter/converter/src/main/java/org/osgi/util/function/Callback.java Thu Oct 27 16:37:16 2016
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) OSGi Alliance (2016). All Rights Reserved.
+ *
+ * Licensed 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.osgi.util.function;
+
+import org.osgi.annotation.versioning.ConsumerType;
+
+/**
+ * A callback that performs an operation and may throw an exception.
+ * <p>
+ * This is a functional interface and can be used as the assignment target for a
+ * lambda expression or method reference.
+ *
+ * @ThreadSafe
+ * @since 1.1
+ * @author $Id: 17ff376bc9c8c171caad89eb9d0bc496f46961ee $
+ */
+@ConsumerType
+@FunctionalInterface
+public interface Callback {
+ /**
+ * Execute the callback.
+ *
+ * @throws Exception An exception thrown by the method.
+ */
+ void run() throws Exception;
+}
Added: felix/trunk/converter/converter/src/main/java/org/osgi/util/function/Function.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/converter/src/main/java/org/osgi/util/function/Function.java?rev=1766855&view=auto
==============================================================================
--- felix/trunk/converter/converter/src/main/java/org/osgi/util/function/Function.java (added)
+++ felix/trunk/converter/converter/src/main/java/org/osgi/util/function/Function.java Thu Oct 27 16:37:16 2016
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) OSGi Alliance (2014, 2016). All Rights Reserved.
+ *
+ * Licensed 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.osgi.util.function;
+
+import org.osgi.annotation.versioning.ConsumerType;
+
+/**
+ * A function that accepts a single argument and produces a result.
+ *
+ * <p>
+ * This is a functional interface and can be used as the assignment target for a
+ * lambda expression or method reference.
+ *
+ * @param <T> The type of the function input.
+ * @param <R> The type of the function output.
+ *
+ * @ThreadSafe
+ * @author $Id: 3d17c97c7dc36185681b98caed5ee10bdeb2cd93 $
+ */
+@ConsumerType
+@FunctionalInterface
+public interface Function<T, R> {
+ /**
+ * Applies this function to the specified argument.
+ *
+ * @param t The input to this function.
+ * @return The output of this function.
+ * @throws Exception An exception thrown by the method.
+ */
+ R apply(T t) throws Exception;
+}
Added: felix/trunk/converter/converter/src/main/java/org/osgi/util/function/Predicate.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/converter/src/main/java/org/osgi/util/function/Predicate.java?rev=1766855&view=auto
==============================================================================
--- felix/trunk/converter/converter/src/main/java/org/osgi/util/function/Predicate.java (added)
+++ felix/trunk/converter/converter/src/main/java/org/osgi/util/function/Predicate.java Thu Oct 27 16:37:16 2016
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) OSGi Alliance (2014, 2016). All Rights Reserved.
+ *
+ * Licensed 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.osgi.util.function;
+
+import org.osgi.annotation.versioning.ConsumerType;
+
+/**
+ * A predicate that accepts a single argument and produces a boolean result.
+ *
+ * <p>
+ * This is a functional interface and can be used as the assignment target for a
+ * lambda expression or method reference.
+ *
+ * @param <T> The type of the predicate input.
+ *
+ * @ThreadSafe
+ * @author $Id: 681b771c26c3d7c2d0719138986947f2592c474c $
+ */
+@ConsumerType
+@FunctionalInterface
+public interface Predicate<T> {
+ /**
+ * Evaluates this predicate on the specified argument.
+ *
+ * @param t The input to this predicate.
+ * @return {@code true} if the specified argument is accepted by this
+ * predicate; {@code false} otherwise.
+ * @throws Exception An exception thrown by the method.
+ */
+ boolean test(T t) throws Exception;
+}
Added: felix/trunk/converter/converter/src/main/java/org/osgi/util/function/package-info.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/converter/src/main/java/org/osgi/util/function/package-info.java?rev=1766855&view=auto
==============================================================================
--- felix/trunk/converter/converter/src/main/java/org/osgi/util/function/package-info.java (added)
+++ felix/trunk/converter/converter/src/main/java/org/osgi/util/function/package-info.java Thu Oct 27 16:37:16 2016
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) OSGi Alliance (2014, 2016). All Rights Reserved.
+ *
+ * Licensed 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.
+ */
+
+/**
+ * Function Package Version 1.1.
+ * <p>
+ * Bundles wishing to use this package must list the package in the
+ * Import-Package header of the bundle's manifest.
+ * <p>
+ * Example import for consumers using the API in this package:
+ * <p>
+ * {@code Import-Package: org.osgi.util.function; version="[1.1,2.0)"}
+ * <p>
+ * Example import for providers implementing the API in this package:
+ * <p>
+ * {@code Import-Package: org.osgi.util.function; version="[1.1,1.2)"}
+ *
+ * @author $Id: 82ed82dc4e9ca67afa2d2616c077fd33bfdee298 $
+ */
+
+@Version("1.1")
+package org.osgi.util.function;
+
+import org.osgi.annotation.versioning.Version;
+