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/10 10:55:03 UTC
svn commit: r1764055 [1/2] - in /felix/trunk/converter: converter/
converter/src/main/java/org/apache/felix/converter/impl/
converter/src/main/java/org/osgi/converter/
converter/src/main/java/org/osgi/service/
converter/src/test/java/org/apache/felix/c...
Author: davidb
Date: Mon Oct 10 10:55:02 2016
New Revision: 1764055
URL: http://svn.apache.org/viewvc?rev=1764055&view=rev
Log:
Felix Converter - rename org.osgi.service.converter to org.osgi.converter.
Added:
felix/trunk/converter/converter/src/main/java/org/osgi/converter/
felix/trunk/converter/converter/src/main/java/org/osgi/converter/ConversionException.java
felix/trunk/converter/converter/src/main/java/org/osgi/converter/ConvertFunction.java
felix/trunk/converter/converter/src/main/java/org/osgi/converter/Converter.java
felix/trunk/converter/converter/src/main/java/org/osgi/converter/ConverterBuilder.java
felix/trunk/converter/converter/src/main/java/org/osgi/converter/Converting.java
felix/trunk/converter/converter/src/main/java/org/osgi/converter/Function.java
felix/trunk/converter/converter/src/main/java/org/osgi/converter/Rule.java
felix/trunk/converter/converter/src/main/java/org/osgi/converter/StandardConverter.java
felix/trunk/converter/converter/src/main/java/org/osgi/converter/TypeReference.java
felix/trunk/converter/converter/src/main/java/org/osgi/converter/package-info.java
felix/trunk/converter/serializer/src/main/java/org/osgi/service/serializer/package-info.java
Removed:
felix/trunk/converter/converter/src/main/java/org/osgi/service/
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/apache/felix/converter/impl/ConverterImpl.java
felix/trunk/converter/converter/src/main/java/org/apache/felix/converter/impl/ConvertingImpl.java
felix/trunk/converter/converter/src/main/java/org/apache/felix/converter/impl/InternalConverter.java
felix/trunk/converter/converter/src/main/java/org/apache/felix/converter/impl/InternalConverting.java
felix/trunk/converter/converter/src/test/java/org/apache/felix/converter/impl/ConverterBuilderTest.java
felix/trunk/converter/converter/src/test/java/org/apache/felix/converter/impl/ConverterMapTest.java
felix/trunk/converter/converter/src/test/java/org/apache/felix/converter/impl/ConverterServiceTest.java
felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/Node.java
felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/Schematizer.java
felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/StandardSchematizer.java
felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/TypeRule.java
felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/CollectionNode.java
felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/NodeImpl.java
felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/SchematizerImpl.java
felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/Util.java
felix/trunk/converter/schematizer/src/main/java/org/apache/felix/serializer/impl/json/JsonDeserializingImpl.java
felix/trunk/converter/schematizer/src/main/java/org/apache/felix/serializer/impl/json/JsonSerializerImpl.java
felix/trunk/converter/schematizer/src/main/java/org/apache/felix/serializer/impl/json/JsonSerializingImpl.java
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/schematizer/impl/SchematizerServiceTest.java
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/impl/json/JsonDeserializationTest.java
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ComplexManagerService.java
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ObjectFactory.java
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/SimpleManagerService.java
felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/DTOSerializer.java
felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/json/JsonDeserializingImpl.java
felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/json/JsonSerializerImpl.java
felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/json/JsonSerializingImpl.java
felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/yaml/YamlDeserializingImpl.java
felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/yaml/YamlSerializerImpl.java
felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/yaml/YamlSerializingImpl.java
felix/trunk/converter/serializer/src/main/java/org/osgi/service/serializer/Deserializing.java
felix/trunk/converter/serializer/src/main/java/org/osgi/service/serializer/Serializer.java
felix/trunk/converter/serializer/src/main/java/org/osgi/service/serializer/Serializing.java
felix/trunk/converter/serializer/src/test/java/org/apache/felix/serializer/impl/json/JsonSerializerTest.java
felix/trunk/converter/serializer/src/test/java/org/apache/felix/serializer/impl/yaml/YamlSerializerTest.java
Modified: felix/trunk/converter/converter/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/converter/converter/pom.xml?rev=1764055&r1=1764054&r2=1764055&view=diff
==============================================================================
--- felix/trunk/converter/converter/pom.xml (original)
+++ felix/trunk/converter/converter/pom.xml Mon Oct 10 10:55:02 2016
@@ -66,8 +66,8 @@
<configuration>
<instructions>
<Private-Package>org.apache.felix.converter.*</Private-Package>
- <Export-Package>org.osgi.service.converter</Export-Package>
- <Import-Package>org.osgi.service.converter, *</Import-Package>
+ <Export-Package>org.osgi.converter</Export-Package>
+ <Import-Package>org.osgi.converter, *</Import-Package>
</instructions>
</configuration>
</plugin>
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=1764055&r1=1764054&r2=1764055&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 Mon Oct 10 10:55:02 2016
@@ -28,14 +28,14 @@ import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
-import org.osgi.service.converter.ConversionException;
-import org.osgi.service.converter.ConvertFunction;
-import org.osgi.service.converter.Converter;
-import org.osgi.service.converter.ConverterBuilder;
-import org.osgi.service.converter.Converting;
-import org.osgi.service.converter.Function;
-import org.osgi.service.converter.Rule;
-import org.osgi.service.converter.TypeReference;
+import org.osgi.converter.ConversionException;
+import org.osgi.converter.ConvertFunction;
+import org.osgi.converter.Converter;
+import org.osgi.converter.ConverterBuilder;
+import org.osgi.converter.Converting;
+import org.osgi.converter.Function;
+import org.osgi.converter.Rule;
+import org.osgi.converter.TypeReference;
public class AdapterImpl implements InternalConverter {
private final InternalConverter delegate;
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=1764055&r1=1764054&r2=1764055&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 Mon Oct 10 10:55:02 2016
@@ -21,10 +21,10 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.felix.converter.impl.AdapterImpl.ConvertFunctionImpl;
-import org.osgi.service.converter.ConverterBuilder;
-import org.osgi.service.converter.Function;
-import org.osgi.service.converter.Rule;
-import org.osgi.service.converter.TypeReference;
+import org.osgi.converter.ConverterBuilder;
+import org.osgi.converter.Function;
+import org.osgi.converter.Rule;
+import org.osgi.converter.TypeReference;
public class ConverterBuilderImpl implements ConverterBuilder {
private final InternalConverter adapter;
Modified: felix/trunk/converter/converter/src/main/java/org/apache/felix/converter/impl/ConverterImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/converter/src/main/java/org/apache/felix/converter/impl/ConverterImpl.java?rev=1764055&r1=1764054&r2=1764055&view=diff
==============================================================================
--- felix/trunk/converter/converter/src/main/java/org/apache/felix/converter/impl/ConverterImpl.java (original)
+++ felix/trunk/converter/converter/src/main/java/org/apache/felix/converter/impl/ConverterImpl.java Mon Oct 10 10:55:02 2016
@@ -28,7 +28,7 @@ import java.util.Date;
import java.util.UUID;
import java.util.regex.Pattern;
-import org.osgi.service.converter.ConverterBuilder;
+import org.osgi.converter.ConverterBuilder;
public class ConverterImpl implements InternalConverter {
@Override
Modified: felix/trunk/converter/converter/src/main/java/org/apache/felix/converter/impl/ConvertingImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/converter/src/main/java/org/apache/felix/converter/impl/ConvertingImpl.java?rev=1764055&r1=1764054&r2=1764055&view=diff
==============================================================================
--- felix/trunk/converter/converter/src/main/java/org/apache/felix/converter/impl/ConvertingImpl.java (original)
+++ felix/trunk/converter/converter/src/main/java/org/apache/felix/converter/impl/ConvertingImpl.java Mon Oct 10 10:55:02 2016
@@ -41,11 +41,11 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
+import org.osgi.converter.ConversionException;
+import org.osgi.converter.Converter;
+import org.osgi.converter.Converting;
+import org.osgi.converter.TypeReference;
import org.osgi.dto.DTO;
-import org.osgi.service.converter.ConversionException;
-import org.osgi.service.converter.Converter;
-import org.osgi.service.converter.Converting;
-import org.osgi.service.converter.TypeReference;
public class ConvertingImpl implements Converting, InternalConverting {
private static final Map<Class<?>, Class<?>> interfaceImplementations;
Modified: felix/trunk/converter/converter/src/main/java/org/apache/felix/converter/impl/InternalConverter.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/converter/src/main/java/org/apache/felix/converter/impl/InternalConverter.java?rev=1764055&r1=1764054&r2=1764055&view=diff
==============================================================================
--- felix/trunk/converter/converter/src/main/java/org/apache/felix/converter/impl/InternalConverter.java (original)
+++ felix/trunk/converter/converter/src/main/java/org/apache/felix/converter/impl/InternalConverter.java Mon Oct 10 10:55:02 2016
@@ -16,7 +16,7 @@
*/
package org.apache.felix.converter.impl;
-import org.osgi.service.converter.Converter;
+import org.osgi.converter.Converter;
public interface InternalConverter extends Converter {
public InternalConverting convert(Object obj);
Modified: felix/trunk/converter/converter/src/main/java/org/apache/felix/converter/impl/InternalConverting.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/converter/src/main/java/org/apache/felix/converter/impl/InternalConverting.java?rev=1764055&r1=1764054&r2=1764055&view=diff
==============================================================================
--- felix/trunk/converter/converter/src/main/java/org/apache/felix/converter/impl/InternalConverting.java (original)
+++ felix/trunk/converter/converter/src/main/java/org/apache/felix/converter/impl/InternalConverting.java Mon Oct 10 10:55:02 2016
@@ -16,8 +16,8 @@
*/
package org.apache.felix.converter.impl;
-import org.osgi.service.converter.Converter;
-import org.osgi.service.converter.Converting;
+import org.osgi.converter.Converter;
+import org.osgi.converter.Converting;
public interface InternalConverting extends Converting {
public void setConverter(Converter c);
Added: felix/trunk/converter/converter/src/main/java/org/osgi/converter/ConversionException.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/converter/src/main/java/org/osgi/converter/ConversionException.java?rev=1764055&view=auto
==============================================================================
--- felix/trunk/converter/converter/src/main/java/org/osgi/converter/ConversionException.java (added)
+++ felix/trunk/converter/converter/src/main/java/org/osgi/converter/ConversionException.java Mon Oct 10 10:55:02 2016
@@ -0,0 +1,44 @@
+/*
+ * 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.converter;
+
+/**
+ * This Runtime Exception is thrown when an object is requested to be converted
+ * but the conversion cannot be done. For example when the String "test" is to
+ * be converted into a Long.
+ */
+public class ConversionException extends RuntimeException {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Create a Conversion Exception with a message.
+ *
+ * @param message The message for this exception.
+ */
+ public ConversionException(String message) {
+ super(message);
+ }
+
+ /**
+ * Create a Conversion Exception with a message and a nested cause.
+ *
+ * @param message The message for this exception.
+ * @param cause The causing exception.
+ */
+ public ConversionException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
Added: felix/trunk/converter/converter/src/main/java/org/osgi/converter/ConvertFunction.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/converter/src/main/java/org/osgi/converter/ConvertFunction.java?rev=1764055&view=auto
==============================================================================
--- felix/trunk/converter/converter/src/main/java/org/osgi/converter/ConvertFunction.java (added)
+++ felix/trunk/converter/converter/src/main/java/org/osgi/converter/ConvertFunction.java Mon Oct 10 10:55:02 2016
@@ -0,0 +1,44 @@
+/*
+ * 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.converter;
+
+import java.lang.reflect.Type;
+
+/**
+ * An functional interface with a single convert method that is passed the
+ * original object and the target type.
+ *
+ * @param <F> Type parameter for the source object.
+ * @param <T> Type parameter for the converted object.
+ * @author $Id$
+ */
+@FunctionalInterface
+public interface ConvertFunction<F, T> {
+ /**
+ * Convert the object into the target type.
+ *
+ * @param obj The object to be converted. This object will never be
+ * {@code null} as the convert function will not be invoked for
+ * null values.
+ * @param targetType The target type.
+ * @return The conversion result or {@code null} to indicate that the
+ * convert function cannot handle this conversion. In this case the
+ * next matching rule or adapter will be given a opportunity to
+ * convert.
+ * @throws Exception
+ */
+ T convert(F obj, Type targetType) throws Exception;
+}
Added: felix/trunk/converter/converter/src/main/java/org/osgi/converter/Converter.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/converter/src/main/java/org/osgi/converter/Converter.java?rev=1764055&view=auto
==============================================================================
--- felix/trunk/converter/converter/src/main/java/org/osgi/converter/Converter.java (added)
+++ felix/trunk/converter/converter/src/main/java/org/osgi/converter/Converter.java Mon Oct 10 10:55:02 2016
@@ -0,0 +1,45 @@
+/*
+ * 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.converter;
+
+import org.osgi.annotation.versioning.ProviderType;
+
+/**
+ * The Converter service is used to start a conversion. The service is obtained
+ * from the service registry. The conversion is then completed via the
+ * Converting interface that has methods to specify the target type.
+ *
+ * @author $Id$
+ * @ThreadSafe
+ */
+@ProviderType
+public interface Converter {
+ /**
+ * Start a conversion for the given object.
+ *
+ * @param obj The object that should be converted.
+ * @return A {@link Converting} object to complete the conversion.
+ */
+ Converting convert(Object obj);
+
+ /**
+ * Obtain a builder to create a modified converter based on this converter.
+ * For more details see the {@link ConverterBuilder} interface.
+ *
+ * @return A new Converter Builder.
+ */
+ ConverterBuilder newConverterBuilder();
+}
Added: felix/trunk/converter/converter/src/main/java/org/osgi/converter/ConverterBuilder.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/converter/src/main/java/org/osgi/converter/ConverterBuilder.java?rev=1764055&view=auto
==============================================================================
--- felix/trunk/converter/converter/src/main/java/org/osgi/converter/ConverterBuilder.java (added)
+++ felix/trunk/converter/converter/src/main/java/org/osgi/converter/ConverterBuilder.java Mon Oct 10 10:55:02 2016
@@ -0,0 +1,80 @@
+/*
+ * 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.converter;
+
+import java.lang.reflect.Type;
+
+/**
+ * A builder to create a new converter with modified behaviour based on an
+ * existing converter. The modified behaviour is specified by providing rules
+ * and/or conversion functions.
+ *
+ * @author $Id$
+ */
+public interface ConverterBuilder {
+ /**
+ * Build the specified converter. Each time this method is called a new
+ * custom converter is produced based on the rules registered with the
+ * builder.
+ *
+ * @return A new converter with the rules provided to the builder.
+ */
+ Converter build();
+
+ /**
+ * Register a special rule for this converter.
+ *
+ * @param rule The rule
+ * @return This converter builder for further building.
+ */
+ <F, T> ConverterBuilder rule(Rule<F,T> rule);
+
+ /**
+ * Register a special rule for this converter.
+ *
+ * @param fromCls The class from which to convert.
+ * @param toCls The class to which to convert.
+ * @param toFun A function that handles the conversion.
+ * @param fromFun A function that handles the reverse conversion.
+ * @return This converter builder for further building.
+ */
+ <F, T> ConverterBuilder rule(Class<F> fromCls, Class<T> toCls,
+ Function<F,T> toFun, Function<T,F> fromFun);
+
+ /**
+ * Register a special rule for this converter.
+ *
+ * @param fromRef A type reference representing the class to convert from.
+ * @param toRef A type reference representing the class to convert to.
+ * @param toFun A function that handles the conversion.
+ * @param fromFun A function that handles the reverse conversion.
+ * @return This converter builder for further building.
+ */
+ <F, T> ConverterBuilder rule(TypeReference<F> fromRef,
+ TypeReference<T> toRef, Function<F,T> toFun, Function<T,F> fromFun);
+
+ /**
+ * Register a special rule for this converter.
+ *
+ * @param fromType A reflection type from which to convert.
+ * @param toType A reflection type to which to convert.
+ * @param toFun A function that handles the conversion.
+ * @param fromFun A function that handles the reverse conversion.
+ * @return This converter builder for further building.
+ */
+ <F, T> ConverterBuilder rule(Type fromType, Type toType,
+ Function<F,T> toFun, Function<T,F> fromFun);
+}
Added: felix/trunk/converter/converter/src/main/java/org/osgi/converter/Converting.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/converter/src/main/java/org/osgi/converter/Converting.java?rev=1764055&view=auto
==============================================================================
--- felix/trunk/converter/converter/src/main/java/org/osgi/converter/Converting.java (added)
+++ felix/trunk/converter/converter/src/main/java/org/osgi/converter/Converting.java Mon Oct 10 10:55:02 2016
@@ -0,0 +1,82 @@
+/*
+ * 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.converter;
+
+import java.lang.reflect.Type;
+
+import org.osgi.annotation.versioning.ProviderType;
+
+/**
+ * This interface is used to specify the target that an object should be
+ * converted to. A {@link Converting} instance can be obtained via the
+ * {@link Converter} service by starting a conversion for a specific object.
+ *
+ * @author $Id$
+ * @ThreadSafe
+ */
+@ProviderType
+public interface Converting {
+ /**
+ * The default value to use when the object cannot be converted or in case
+ * of conversion from a {@code null} value.
+ *
+ * @param defVal The default value.
+ * @return The current {@code Converting} object so that additional calls
+ * can be chained.
+ */
+ Converting defaultValue(Object defVal);
+
+ /**
+ * Specify the target object type for the conversion as a class object.
+ *
+ * @param cls The class to convert to.
+ * @return The converted object.
+ */
+ <T> T to(Class<T> cls);
+
+ /**
+ * Specify the target object type as a {@link TypeReference}. If the target
+ * class carries generics information a TypeReference should be used as this
+ * preserves the generic information whereas a Class object has this
+ * information erased. Example use:
+ *
+ * <pre>
+ * List<String> result = converter.convert(Arrays.asList(1, 2, 3))
+ * .to(new TypeReference<List<String>>() {});
+ * </pre>
+ *
+ * @param ref A type reference to the object being converted to.
+ * @return The converted object.
+ */
+ <T> T to(TypeReference<T> ref);
+
+ /**
+ * Specify the target object type as a Java Reflection Type object.
+ *
+ * @param type A Type object to represent the target type to be converted
+ * to.
+ * @return The converted object.
+ */
+ Object to(Type type);
+
+ /**
+ * Same as {@code to(String.class)}.
+ *
+ * @return The converted object.
+ */
+ @Override
+ String toString();
+}
Added: felix/trunk/converter/converter/src/main/java/org/osgi/converter/Function.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/converter/src/main/java/org/osgi/converter/Function.java?rev=1764055&view=auto
==============================================================================
--- felix/trunk/converter/converter/src/main/java/org/osgi/converter/Function.java (added)
+++ felix/trunk/converter/converter/src/main/java/org/osgi/converter/Function.java Mon Oct 10 10:55:02 2016
@@ -0,0 +1,43 @@
+/*
+ * 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.converter;
+
+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/converter/Rule.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/converter/src/main/java/org/osgi/converter/Rule.java?rev=1764055&view=auto
==============================================================================
--- felix/trunk/converter/converter/src/main/java/org/osgi/converter/Rule.java (added)
+++ felix/trunk/converter/converter/src/main/java/org/osgi/converter/Rule.java Mon Oct 10 10:55:02 2016
@@ -0,0 +1,115 @@
+/*
+ * 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.converter;
+
+/**
+ * A rule is a data entity can hold all the information needed to specify a
+ * custom conversion for use by the {@link ConverterBuilder}.
+ *
+ * @param <F> The type to convert from.
+ * @param <T> The type to convert to.
+ * @author $Id: 7f624253be48fc23d8a793b38673305dbfd5ff9a $
+ * @Immutable
+ */
+public class Rule<F, T> {
+ private final Class<F> fromClass;
+ private final Class<T> toClass;
+ private final ConvertFunction<T,F> fromFun;
+ private final ConvertFunction<F,T> toFun;
+
+ /**
+ * Create a bidirectional rule.
+ *
+ * @param fromCls The class from which to convert. If {@link Object} is
+ * specified then this functions as a wildcard for generic
+ * conversions.
+ * @param toCls The class to which to convert. If {@link Object} is
+ * specified then this functions as a wildcard for generic
+ * conversions.
+ * @param to The conversion function for this rule.
+ * @param from The reverse conversion for this rule.
+ */
+ public Rule(Class<F> fromCls, Class<T> toCls, ConvertFunction<F,T> to,
+ ConvertFunction<T,F> from) {
+ if (fromCls.equals(toCls)) {
+ if (fromCls.equals(Object.class)) {
+ if (from != null) {
+ throw new IllegalStateException(
+ "Can only register one catchall converter");
+ }
+ } else {
+ throw new IllegalStateException(
+ "Cannot register a convert to itself");
+ }
+ }
+
+ fromClass = fromCls;
+ toClass = toCls;
+ toFun = to;
+ fromFun = from;
+ }
+
+ /**
+ * Create a single-direction rule.
+ *
+ * @param fromCls The class from which to convert. If {@link Object} is
+ * specified then this functions as a wildcard for generic
+ * conversions.
+ * @param toCls The class to which to convert. If {@link Object} is
+ * specified then this functions as a wildcard for generic
+ * conversions.
+ * @param to The conversion function for this rule.
+ */
+ public Rule(Class<F> fromCls, Class<T> toCls, ConvertFunction<F,T> to) {
+ this(fromCls, toCls, to, null);
+ }
+
+ /**
+ * Accessor for the class to convert from.
+ *
+ * @return The class to convert from.
+ */
+ public Class<F> getFromClass() {
+ return fromClass;
+ }
+
+ /**
+ * Accessor for the class to convert to.
+ *
+ * @return The class to convert to.
+ */
+ public Class<T> getToClass() {
+ return toClass;
+ }
+
+ /**
+ * Obtain the conversion function.
+ *
+ * @return The conversion function.
+ */
+ public ConvertFunction<F,T> getToFunction() {
+ return toFun;
+ }
+
+ /**
+ * Obtain the reverse conversion function.
+ *
+ * @return The reverse conversion function.
+ */
+ public ConvertFunction<T,F> getFromFunction() {
+ return fromFun;
+ }
+}
Added: felix/trunk/converter/converter/src/main/java/org/osgi/converter/StandardConverter.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/converter/src/main/java/org/osgi/converter/StandardConverter.java?rev=1764055&view=auto
==============================================================================
--- felix/trunk/converter/converter/src/main/java/org/osgi/converter/StandardConverter.java (added)
+++ felix/trunk/converter/converter/src/main/java/org/osgi/converter/StandardConverter.java Mon Oct 10 10:55:02 2016
@@ -0,0 +1,42 @@
+/*
+ * 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.osgi.converter;
+
+import org.apache.felix.converter.impl.ConverterBuilderImpl;
+import org.apache.felix.converter.impl.ConverterImpl;
+import org.apache.felix.converter.impl.InternalConverter;
+
+public class StandardConverter implements Converter {
+ private final InternalConverter converter;
+
+ public StandardConverter() {
+ ConverterImpl impl = new ConverterImpl();
+ ConverterBuilderImpl cb = impl.newConverterBuilder();
+ impl.addStandardRules(cb);
+ converter = cb.build();
+ }
+
+ @Override
+ public Converting convert(Object obj) {
+ return converter.convert(obj);
+ }
+
+ @Override
+ public ConverterBuilder newConverterBuilder() {
+ return converter.newConverterBuilder();
+ }
+}
Added: felix/trunk/converter/converter/src/main/java/org/osgi/converter/TypeReference.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/converter/src/main/java/org/osgi/converter/TypeReference.java?rev=1764055&view=auto
==============================================================================
--- felix/trunk/converter/converter/src/main/java/org/osgi/converter/TypeReference.java (added)
+++ felix/trunk/converter/converter/src/main/java/org/osgi/converter/TypeReference.java Mon Oct 10 10:55:02 2016
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) OSGi Alliance (2015, 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.converter;
+
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+
+import org.osgi.annotation.versioning.ConsumerType;
+
+/**
+ * An object does not carry any runtime information about its generic type.
+ * However sometimes it is necessary to specify a generic type, that is the
+ * purpose of this class. It allows you to specify an generic type by defining a
+ * type T, then subclassing it. The subclass will have a reference to the super
+ * class that contains this generic information. Through reflection, we pick
+ * this reference up and return it with the getType() call.
+ *
+ * <pre>
+ * List<String> result = converter.convert(Arrays.asList(1, 2, 3))
+ * .to(new TypeReference<List<String>>() {});
+ * </pre>
+ *
+ * @param <T> The target type for the conversion.
+ * @author $Id$
+ * @Immutable
+ */
+@ConsumerType
+public class TypeReference<T> {
+ /**
+ * A {@link TypeReference} cannot be directly instantiated. To use it, it
+ * has to be extended, typically as an anonymous inner class.
+ */
+ protected TypeReference() {}
+
+ /**
+ * Return the actual type of this Type Reference
+ *
+ * @return the type of this reference.
+ */
+ public Type getType() {
+ return ((ParameterizedType) getClass().getGenericSuperclass())
+ .getActualTypeArguments()[0];
+ }
+}
Added: felix/trunk/converter/converter/src/main/java/org/osgi/converter/package-info.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/converter/src/main/java/org/osgi/converter/package-info.java?rev=1764055&view=auto
==============================================================================
--- felix/trunk/converter/converter/src/main/java/org/osgi/converter/package-info.java (added)
+++ felix/trunk/converter/converter/src/main/java/org/osgi/converter/package-info.java Mon Oct 10 10:55:02 2016
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+
+/**
+ * Converter Package Version 1.0.
+ * <p>
+ * Bundles wishing to use this package must list the package in the
+ * Import-Package header of the bundle's manifest. This package has two types of
+ * users: the consumers that use the API in this package and the providers that
+ * implement the API in this package.
+ * <p>
+ * Example import for consumers using the API in this package:
+ * <p>
+ * {@code Import-Package: org.osgi.converter; version="[1.0,2.0)"}
+ * <p>
+ * Example import for providers implementing the API in this package:
+ * <p>
+ * {@code Import-Package: org.osgi.converter; version="[1.0,1.1)"}
+ *
+ * @author $Id: 1b82a2a1db1431c5e4398f368662b5b6fb5f8547 $
+ */
+@Version("1.0")
+package org.osgi.converter;
+
+import org.osgi.annotation.versioning.Version;
Modified: felix/trunk/converter/converter/src/test/java/org/apache/felix/converter/impl/ConverterBuilderTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/converter/src/test/java/org/apache/felix/converter/impl/ConverterBuilderTest.java?rev=1764055&r1=1764054&r2=1764055&view=diff
==============================================================================
--- felix/trunk/converter/converter/src/test/java/org/apache/felix/converter/impl/ConverterBuilderTest.java (original)
+++ felix/trunk/converter/converter/src/test/java/org/apache/felix/converter/impl/ConverterBuilderTest.java Mon Oct 10 10:55:02 2016
@@ -30,10 +30,10 @@ import java.util.stream.Stream;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import org.osgi.service.converter.ConvertFunction;
-import org.osgi.service.converter.Converter;
-import org.osgi.service.converter.ConverterBuilder;
-import org.osgi.service.converter.Rule;
+import org.osgi.converter.ConvertFunction;
+import org.osgi.converter.Converter;
+import org.osgi.converter.ConverterBuilder;
+import org.osgi.converter.Rule;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
Modified: felix/trunk/converter/converter/src/test/java/org/apache/felix/converter/impl/ConverterMapTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/converter/src/test/java/org/apache/felix/converter/impl/ConverterMapTest.java?rev=1764055&r1=1764054&r2=1764055&view=diff
==============================================================================
--- felix/trunk/converter/converter/src/test/java/org/apache/felix/converter/impl/ConverterMapTest.java (original)
+++ felix/trunk/converter/converter/src/test/java/org/apache/felix/converter/impl/ConverterMapTest.java Mon Oct 10 10:55:02 2016
@@ -28,10 +28,10 @@ import java.util.Map;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import org.osgi.service.converter.Converter;
-import org.osgi.service.converter.ConverterBuilder;
-import org.osgi.service.converter.StandardConverter;
-import org.osgi.service.converter.TypeReference;
+import org.osgi.converter.Converter;
+import org.osgi.converter.ConverterBuilder;
+import org.osgi.converter.StandardConverter;
+import org.osgi.converter.TypeReference;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
Modified: felix/trunk/converter/converter/src/test/java/org/apache/felix/converter/impl/ConverterServiceTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/converter/src/test/java/org/apache/felix/converter/impl/ConverterServiceTest.java?rev=1764055&r1=1764054&r2=1764055&view=diff
==============================================================================
--- felix/trunk/converter/converter/src/test/java/org/apache/felix/converter/impl/ConverterServiceTest.java (original)
+++ felix/trunk/converter/converter/src/test/java/org/apache/felix/converter/impl/ConverterServiceTest.java Mon Oct 10 10:55:02 2016
@@ -51,11 +51,11 @@ import org.apache.felix.converter.impl.M
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import org.osgi.service.converter.ConversionException;
-import org.osgi.service.converter.Converter;
-import org.osgi.service.converter.ConverterBuilder;
-import org.osgi.service.converter.StandardConverter;
-import org.osgi.service.converter.TypeReference;
+import org.osgi.converter.ConversionException;
+import org.osgi.converter.Converter;
+import org.osgi.converter.ConverterBuilder;
+import org.osgi.converter.StandardConverter;
+import org.osgi.converter.TypeReference;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
Modified: felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/Node.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/Node.java?rev=1764055&r1=1764054&r2=1764055&view=diff
==============================================================================
--- felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/Node.java (original)
+++ felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/Node.java Mon Oct 10 10:55:02 2016
@@ -25,7 +25,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
-import org.osgi.service.converter.TypeReference;
+import org.osgi.converter.TypeReference;
public interface Node {
Modified: felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/Schematizer.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/Schematizer.java?rev=1764055&r1=1764054&r2=1764055&view=diff
==============================================================================
--- felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/Schematizer.java (original)
+++ felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/Schematizer.java Mon Oct 10 10:55:02 2016
@@ -19,8 +19,8 @@ import java.util.Map;
import java.util.Optional;
import org.osgi.annotation.versioning.ProviderType;
+import org.osgi.converter.TypeReference;
import org.osgi.dto.DTO;
-import org.osgi.service.converter.TypeReference;
@ProviderType
public interface Schematizer {
Modified: felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/StandardSchematizer.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/StandardSchematizer.java?rev=1764055&r1=1764054&r2=1764055&view=diff
==============================================================================
--- felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/StandardSchematizer.java (original)
+++ felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/StandardSchematizer.java Mon Oct 10 10:55:02 2016
@@ -19,8 +19,8 @@ package org.apache.felix.schematizer;
import java.util.Map;
import java.util.Optional;
+import org.osgi.converter.TypeReference;
import org.osgi.dto.DTO;
-import org.osgi.service.converter.TypeReference;
public class StandardSchematizer implements Schematizer {
private final Schematizer schematizer;
Modified: felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/TypeRule.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/TypeRule.java?rev=1764055&r1=1764054&r2=1764055&view=diff
==============================================================================
--- felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/TypeRule.java (original)
+++ felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/TypeRule.java Mon Oct 10 10:55:02 2016
@@ -15,7 +15,7 @@
*/
package org.apache.felix.schematizer;
-import org.osgi.service.converter.TypeReference;
+import org.osgi.converter.TypeReference;
public class TypeRule<T> {
private final String path;
Modified: felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/CollectionNode.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/CollectionNode.java?rev=1764055&r1=1764054&r2=1764055&view=diff
==============================================================================
--- felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/CollectionNode.java (original)
+++ felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/CollectionNode.java Mon Oct 10 10:55:02 2016
@@ -18,7 +18,7 @@ package org.apache.felix.schematizer.imp
import java.lang.reflect.Type;
import java.util.Collection;
-import org.osgi.service.converter.TypeReference;
+import org.osgi.converter.TypeReference;
public class CollectionNode
extends NodeImpl
Modified: felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/NodeImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/NodeImpl.java?rev=1764055&r1=1764054&r2=1764055&view=diff
==============================================================================
--- felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/NodeImpl.java (original)
+++ felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/NodeImpl.java Mon Oct 10 10:55:02 2016
@@ -23,7 +23,7 @@ import java.util.Optional;
import java.util.function.Function;
import org.apache.felix.schematizer.Node;
-import org.osgi.service.converter.TypeReference;
+import org.osgi.converter.TypeReference;
public class NodeImpl implements Node {
Modified: felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/SchematizerImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/SchematizerImpl.java?rev=1764055&r1=1764054&r2=1764055&view=diff
==============================================================================
--- felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/SchematizerImpl.java (original)
+++ felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/SchematizerImpl.java Mon Oct 10 10:55:02 2016
@@ -27,9 +27,9 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Optional;
import java.util.Set;
-import java.util.Map.Entry;
import java.util.function.Function;
import java.util.stream.Collectors;
@@ -38,8 +38,8 @@ import org.apache.felix.schematizer.Node
import org.apache.felix.schematizer.Schema;
import org.apache.felix.schematizer.Schematizer;
import org.apache.felix.schematizer.TypeRule;
+import org.osgi.converter.TypeReference;
import org.osgi.dto.DTO;
-import org.osgi.service.converter.TypeReference;
public class SchematizerImpl implements Schematizer {
@@ -122,8 +122,8 @@ public class SchematizerImpl implements
* Schematize any node, without knowing in advance its type.
*/
private static SchemaImpl internalSchematize(
- String name,
- String contextPath,
+ String name,
+ String contextPath,
Map<String, Object> rules,
boolean isCollection,
SchematizerImpl schematizer) {
@@ -149,16 +149,16 @@ public class SchematizerImpl implements
if (DTO.class.isAssignableFrom(cls)) {
Class<? extends DTO> targetCls = (Class<DTO>)cls;
- return schematizeDTO(name, targetCls, ref, contextPath, rules, isCollection, schematizer);
+ return schematizeDTO(name, targetCls, ref, contextPath, rules, isCollection, schematizer);
}
return schematizeObject( name, cls, contextPath, rules, isCollection, schematizer);
}
private static SchemaImpl schematizeDTO(
- String name,
- Class<? extends DTO> targetCls,
- TypeReference<? extends DTO> ref,
+ String name,
+ Class<? extends DTO> targetCls,
+ TypeReference<? extends DTO> ref,
String contextPath,
Map<String, Object> rules,
boolean isCollection,
@@ -179,7 +179,7 @@ public class SchematizerImpl implements
}
private static SchemaImpl schematizeObject(
- String name,
+ String name,
Class<?> targetCls,
String contextPath,
Map<String, Object> rules,
@@ -199,9 +199,9 @@ public class SchematizerImpl implements
private static final Comparator<Entry<String, NodeImpl>> byPath = (e1, e2) -> e1.getValue().absolutePath().compareTo(e2.getValue().absolutePath());
private static Map<String, NodeImpl> createMapFromDTO(
String name,
- Class<?> targetCls,
- TypeReference<? extends DTO> ref,
- String contextPath,
+ Class<?> targetCls,
+ TypeReference<? extends DTO> ref,
+ String contextPath,
Map<String, Object> typeRules,
SchematizerImpl schematizer) {
Set<String> handledFields = new HashSet<>();
@@ -220,11 +220,11 @@ public class SchematizerImpl implements
@SuppressWarnings( { "rawtypes", "unchecked" } )
private static void handleField(
String name,
- Field field,
- Set<String> handledFields,
- Map<String, NodeImpl> result,
- Class<?> targetCls,
- TypeReference<?> ref,
+ Field field,
+ Set<String> handledFields,
+ Map<String, NodeImpl> result,
+ Class<?> targetCls,
+ TypeReference<?> ref,
String contextPath,
Map<String, Object> rules,
SchematizerImpl schematizer) {
@@ -239,7 +239,7 @@ public class SchematizerImpl implements
String path = contextPath + "/" + fieldName;
NodeImpl node;
if (rules.containsKey(path)) {
- // The actual field. Since the type for this node is provided as a rule, we
+ // The actual field. Since the type for this node is provided as a rule, we
// only need it to test whether or not it is a collection.
Class<?> actualFieldType = field.getType();
boolean isCollection = Collection.class.isAssignableFrom(actualFieldType);
@@ -250,8 +250,8 @@ public class SchematizerImpl implements
TypeReference fieldRef = typeReferenceOf(rules.get(path));
if (isCollection)
node = new CollectionNode(
- field.getName(),
- fieldRef,
+ field.getName(),
+ fieldRef,
path,
(Class)actualFieldType);
else if (fieldRef != null )
@@ -278,8 +278,8 @@ public class SchematizerImpl implements
else
collectionType = Object.class;
node = new CollectionNode(
- field.getName(),
- collectionType,
+ field.getName(),
+ collectionType,
path,
(Class)fieldClass);
@@ -305,7 +305,7 @@ public class SchematizerImpl implements
newSchematizer.rule(path, path, fieldClass);
SchemaImpl embedded = newSchematizer.schematize(path, path);
node = new NodeImpl(
- field.getName(),
+ field.getName(),
fieldClass,
false,
path);
@@ -318,9 +318,9 @@ public class SchematizerImpl implements
node.add(childNodes);
} else {
node = new NodeImpl(
- field.getName(),
- fieldClass,
- false,
+ field.getName(),
+ fieldClass,
+ false,
path);
}
}
Modified: felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/Util.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/Util.java?rev=1764055&r1=1764054&r2=1764055&view=diff
==============================================================================
--- felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/Util.java (original)
+++ felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/Util.java Mon Oct 10 10:55:02 2016
@@ -25,7 +25,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
-import org.osgi.service.converter.TypeReference;
+import org.osgi.converter.TypeReference;
public class Util {
private static final Map<Class<?>, Class<?>> boxedClasses;
Modified: felix/trunk/converter/schematizer/src/main/java/org/apache/felix/serializer/impl/json/JsonDeserializingImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/main/java/org/apache/felix/serializer/impl/json/JsonDeserializingImpl.java?rev=1764055&r1=1764054&r2=1764055&view=diff
==============================================================================
--- felix/trunk/converter/schematizer/src/main/java/org/apache/felix/serializer/impl/json/JsonDeserializingImpl.java (original)
+++ felix/trunk/converter/schematizer/src/main/java/org/apache/felix/serializer/impl/json/JsonDeserializingImpl.java Mon Oct 10 10:55:02 2016
@@ -32,10 +32,10 @@ import java.util.Scanner;
import org.apache.felix.schematizer.Node;
import org.apache.felix.schematizer.Schema;
import org.apache.felix.schematizer.impl.Util;
+import org.osgi.converter.ConversionException;
+import org.osgi.converter.Converter;
+import org.osgi.converter.TypeReference;
import org.osgi.dto.DTO;
-import org.osgi.service.converter.ConversionException;
-import org.osgi.service.converter.Converter;
-import org.osgi.service.converter.TypeReference;
import org.osgi.service.serializer.Deserializing;
public class JsonDeserializingImpl<T> implements Deserializing<T> {
@@ -49,14 +49,13 @@ public class JsonDeserializingImpl<T> im
}
@Override
- public Deserializing<T> with(Converter c)
+ public JsonDeserializingImpl<T> with(Converter c)
{
converter = c;
return this;
}
- @Override
- public Deserializing<T> withContext(Object obj)
+ public JsonDeserializingImpl<T> withContext(Object obj)
{
if(obj instanceof Schema)
schema = (Schema)obj;
@@ -124,10 +123,10 @@ public class JsonDeserializingImpl<T> im
}
if (cls == null)
- return (T)handleInvalid();
+ return handleInvalid();
if (!DTO.class.isAssignableFrom(cls))
- return (T)handleInvalid();
+ return handleInvalid();
Class<? extends DTO> targetCls = (Class)cls;
@@ -170,7 +169,7 @@ public class JsonDeserializingImpl<T> im
else if (DTO.class.isAssignableFrom(Util.rawClassOf(type)))
c.add(convertToDTO((Class)Util.rawClassOf(type), (Map)o, schema, path + "/"));
else
- c.add(converter.convert(c).to(type));
+ c.add(converter.convert(c).to(type));
}
obj = c;
} else {
@@ -180,11 +179,11 @@ public class JsonDeserializingImpl<T> im
else if (DTO.class.isAssignableFrom(Util.rawClassOf(type)))
obj = convertToDTO((Class)Util.rawClassOf(type), (Map)val, schema, path + "/");
else
- obj = converter.convert(val).to(type);
+ obj = converter.convert(val).to(type);
}
}
- f.set(dto, obj);
+ f.set(dto, obj);
}
} catch (NoSuchFieldException e) {
}
@@ -224,7 +223,7 @@ public class JsonDeserializingImpl<T> im
{
if (DTO.class.isAssignableFrom(targetCls ))
return convertCollectionItemToDTO(obj, targetCls, schema, path);
-
+
U newItem = targetCls.newInstance();
return newItem;
}
Modified: felix/trunk/converter/schematizer/src/main/java/org/apache/felix/serializer/impl/json/JsonSerializerImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/main/java/org/apache/felix/serializer/impl/json/JsonSerializerImpl.java?rev=1764055&r1=1764054&r2=1764055&view=diff
==============================================================================
--- felix/trunk/converter/schematizer/src/main/java/org/apache/felix/serializer/impl/json/JsonSerializerImpl.java (original)
+++ felix/trunk/converter/schematizer/src/main/java/org/apache/felix/serializer/impl/json/JsonSerializerImpl.java Mon Oct 10 10:55:02 2016
@@ -24,10 +24,9 @@ import java.nio.charset.StandardCharsets
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import org.osgi.service.converter.Converter;
-import org.osgi.service.converter.StandardConverter;
-import org.osgi.service.converter.TypeReference;
-import org.osgi.service.serializer.Deserializing;
+import org.osgi.converter.Converter;
+import org.osgi.converter.StandardConverter;
+import org.osgi.converter.TypeReference;
import org.osgi.service.serializer.Serializer;
import org.osgi.service.serializer.Serializing;
@@ -37,7 +36,7 @@ public class JsonSerializerImpl implemen
private final Converter converter = new StandardConverter();
@Override
- public <T> Deserializing<T> deserialize(Class<T> cls) {
+ public <T> JsonDeserializingImpl<T> deserialize(Class<T> cls) {
return new JsonDeserializingImpl<T>(converter, cls);
}
@@ -120,12 +119,12 @@ public class JsonSerializerImpl implemen
}
@Override
- public <T> Deserializing<T> deserialize(TypeReference<T> ref) {
+ public <T> JsonDeserializingImpl<T> deserialize(TypeReference<T> ref) {
return new JsonDeserializingImpl<>(converter, ref);
}
@Override
- public Deserializing<?> deserialize(Type type) {
+ public JsonDeserializingImpl<?> deserialize(Type type) {
return new JsonDeserializingImpl<>(converter, type);
}
}
Modified: felix/trunk/converter/schematizer/src/main/java/org/apache/felix/serializer/impl/json/JsonSerializingImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/main/java/org/apache/felix/serializer/impl/json/JsonSerializingImpl.java?rev=1764055&r1=1764054&r2=1764055&view=diff
==============================================================================
--- felix/trunk/converter/schematizer/src/main/java/org/apache/felix/serializer/impl/json/JsonSerializingImpl.java (original)
+++ felix/trunk/converter/schematizer/src/main/java/org/apache/felix/serializer/impl/json/JsonSerializingImpl.java Mon Oct 10 10:55:02 2016
@@ -28,9 +28,9 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
+import org.osgi.converter.ConversionException;
+import org.osgi.converter.Converter;
import org.osgi.dto.DTO;
-import org.osgi.service.converter.ConversionException;
-import org.osgi.service.converter.Converter;
import org.osgi.service.serializer.Serializing;
public class JsonSerializingImpl implements Serializing {
Modified: felix/trunk/converter/schematizer/src/test/java/org/apache/felix/schematizer/impl/SchematizerServiceTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/test/java/org/apache/felix/schematizer/impl/SchematizerServiceTest.java?rev=1764055&r1=1764054&r2=1764055&view=diff
==============================================================================
--- felix/trunk/converter/schematizer/src/test/java/org/apache/felix/schematizer/impl/SchematizerServiceTest.java (original)
+++ felix/trunk/converter/schematizer/src/test/java/org/apache/felix/schematizer/impl/SchematizerServiceTest.java Mon Oct 10 10:55:02 2016
@@ -24,9 +24,9 @@ import org.apache.felix.schematizer.Sche
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import org.osgi.service.converter.Converter;
-import org.osgi.service.converter.StandardConverter;
-import org.osgi.service.converter.TypeReference;
+import org.osgi.converter.Converter;
+import org.osgi.converter.StandardConverter;
+import org.osgi.converter.TypeReference;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
Modified: felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/impl/json/JsonDeserializationTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/impl/json/JsonDeserializationTest.java?rev=1764055&r1=1764054&r2=1764055&view=diff
==============================================================================
--- felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/impl/json/JsonDeserializationTest.java (original)
+++ felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/impl/json/JsonDeserializationTest.java Mon Oct 10 10:55:02 2016
@@ -16,6 +16,9 @@
*/
package org.apache.felix.serializer.impl.json;
+import java.util.ArrayList;
+import java.util.Optional;
+
import org.apache.felix.schematizer.Schema;
import org.apache.felix.schematizer.impl.SchematizerImpl;
import org.apache.felix.serializer.impl.json.MyDTO.Count;
@@ -23,16 +26,13 @@ import org.apache.felix.serializer.impl.
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import org.osgi.service.converter.Converter;
-import org.osgi.service.converter.StandardConverter;
-import org.osgi.service.converter.TypeReference;
+import org.osgi.converter.Converter;
+import org.osgi.converter.StandardConverter;
+import org.osgi.converter.TypeReference;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import java.util.ArrayList;
-import java.util.Optional;
-
public class JsonDeserializationTest {
private Converter converter;
@@ -70,6 +70,7 @@ public class JsonDeserializationTest {
assertTrue(opt.isPresent());
Schema s = opt.get();
+
MyDTO result = new JsonSerializerImpl()
.deserialize(MyDTO.class)
.with(converter)
@@ -106,7 +107,8 @@ public class JsonDeserializationTest {
assertTrue(opt.isPresent());
Schema s = opt.get();
- MyDTO2<MyEmbeddedDTO2<String>> result = new JsonSerializerImpl()
+ MyDTO2<MyEmbeddedDTO2<String>> result =
+ new JsonSerializerImpl()
.deserialize(new TypeReference<MyDTO2<MyEmbeddedDTO2<String>>>(){})
.with(converter)
.withContext(s)
Modified: felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ComplexManagerService.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ComplexManagerService.java?rev=1764055&r1=1764054&r2=1764055&view=diff
==============================================================================
--- felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ComplexManagerService.java (original)
+++ felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ComplexManagerService.java Mon Oct 10 10:55:02 2016
@@ -28,7 +28,7 @@ import org.apache.felix.serializer.test.
import org.apache.felix.serializer.test.prevayler.AggregateTypeReference;
import org.apache.felix.serializer.test.prevayler.MockPrevaylerBackedRepository;
import org.apache.felix.serializer.test.prevayler.Repository;
-import org.osgi.service.converter.TypeReference;
+import org.osgi.converter.TypeReference;
public class ComplexManagerService
implements ComplexManager
@@ -64,7 +64,7 @@ public class ComplexManagerService
@Override
public List<ComplexTop> list()
{
- return repository.list().stream().map(e -> (ComplexTopEntity)e).collect(Collectors.toList());
+ return repository.list().stream().map(e -> e).collect(Collectors.toList());
}
@Override
@@ -74,12 +74,12 @@ public class ComplexManagerService
@Override
public void delete(String key) {
- repository.remove(key);
+ repository.remove(key);
}
@Override
public void clear() {
- repository.clear();
+ repository.clear();
}
@SuppressWarnings( { "unchecked", "rawtypes" } )
Modified: felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ObjectFactory.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ObjectFactory.java?rev=1764055&r1=1764054&r2=1764055&view=diff
==============================================================================
--- felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ObjectFactory.java (original)
+++ felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ObjectFactory.java Mon Oct 10 10:55:02 2016
@@ -18,8 +18,8 @@ package org.apache.felix.serializer.test
import java.util.Collection;
-import org.osgi.service.converter.Converter;
-import org.osgi.service.converter.StandardConverter;
+import org.osgi.converter.Converter;
+import org.osgi.converter.StandardConverter;
public class ObjectFactory
{
Modified: felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/SimpleManagerService.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/SimpleManagerService.java?rev=1764055&r1=1764054&r2=1764055&view=diff
==============================================================================
--- felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/SimpleManagerService.java (original)
+++ felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/SimpleManagerService.java Mon Oct 10 10:55:02 2016
@@ -27,7 +27,7 @@ import org.apache.felix.serializer.test.
import org.apache.felix.serializer.test.prevayler.AggregateTypeReference;
import org.apache.felix.serializer.test.prevayler.MockPrevaylerBackedRepository;
import org.apache.felix.serializer.test.prevayler.Repository;
-import org.osgi.service.converter.TypeReference;
+import org.osgi.converter.TypeReference;
public class SimpleManagerService
implements SimpleManager
@@ -49,7 +49,7 @@ public class SimpleManagerService
@Override
public void add( SimpleTop top ) {
- repository.put( top.getId(), (SimpleTopEntity)top );
+ repository.put( top.getId(), (SimpleTopEntity)top );
}
@Override
@@ -69,12 +69,12 @@ public class SimpleManagerService
@Override
public void delete(String key) {
- repository.remove(key);
+ repository.remove(key);
}
@Override
public void clear() {
- repository.clear();
+ repository.clear();
}
@SuppressWarnings( { "unchecked", "rawtypes" } )
Modified: felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/DTOSerializer.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/DTOSerializer.java?rev=1764055&r1=1764054&r2=1764055&view=diff
==============================================================================
--- felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/DTOSerializer.java (original)
+++ felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/DTOSerializer.java Mon Oct 10 10:55:02 2016
@@ -31,22 +31,21 @@ import org.apache.felix.schematizer.Sche
import org.apache.felix.schematizer.TypeRule;
import org.apache.felix.schematizer.impl.SchematizerImpl;
import org.apache.felix.serializer.impl.json.JsonSerializerImpl;
-import org.osgi.service.converter.Converter;
-import org.osgi.service.converter.StandardConverter;
-import org.osgi.service.converter.TypeReference;
-import org.osgi.service.serializer.Serializer;
+import org.osgi.converter.Converter;
+import org.osgi.converter.StandardConverter;
+import org.osgi.converter.TypeReference;
public class DTOSerializer<C extends CommandDTO<?>>
{
private static final int MARKER_LENGTH = 10;
private final Converter converter = new StandardConverter();
- private final Serializer serializer = new JsonSerializerImpl();
+ private final JsonSerializerImpl serializer = new JsonSerializerImpl();
private final List<TypeRule<?>> rules;
private final Map<String, Schema> schemas = new HashMap<>();
private final Class<?> entityType;
- public DTOSerializer(
+ public DTOSerializer(
List<TypeRule<?>> aRulesList,
Class<?> anEntityType )
{
Modified: felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/json/JsonDeserializingImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/json/JsonDeserializingImpl.java?rev=1764055&r1=1764054&r2=1764055&view=diff
==============================================================================
--- felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/json/JsonDeserializingImpl.java (original)
+++ felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/json/JsonDeserializingImpl.java Mon Oct 10 10:55:02 2016
@@ -25,8 +25,8 @@ import java.util.Map;
import java.util.Scanner;
import org.apache.felix.converter.impl.Util;
-import org.osgi.service.converter.ConversionException;
-import org.osgi.service.converter.Converter;
+import org.osgi.converter.ConversionException;
+import org.osgi.converter.Converter;
import org.osgi.service.serializer.Deserializing;
public class JsonDeserializingImpl<T> implements Deserializing<T> {
Modified: felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/json/JsonSerializerImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/json/JsonSerializerImpl.java?rev=1764055&r1=1764054&r2=1764055&view=diff
==============================================================================
--- felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/json/JsonSerializerImpl.java (original)
+++ felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/json/JsonSerializerImpl.java Mon Oct 10 10:55:02 2016
@@ -24,9 +24,9 @@ import java.nio.charset.StandardCharsets
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import org.osgi.service.converter.Converter;
-import org.osgi.service.converter.StandardConverter;
-import org.osgi.service.converter.TypeReference;
+import org.osgi.converter.Converter;
+import org.osgi.converter.StandardConverter;
+import org.osgi.converter.TypeReference;
import org.osgi.service.serializer.Deserializing;
import org.osgi.service.serializer.Serializer;
import org.osgi.service.serializer.Serializing;
Modified: felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/json/JsonSerializingImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/json/JsonSerializingImpl.java?rev=1764055&r1=1764054&r2=1764055&view=diff
==============================================================================
--- felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/json/JsonSerializingImpl.java (original)
+++ felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/json/JsonSerializingImpl.java Mon Oct 10 10:55:02 2016
@@ -28,9 +28,9 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
+import org.osgi.converter.ConversionException;
+import org.osgi.converter.Converter;
import org.osgi.dto.DTO;
-import org.osgi.service.converter.ConversionException;
-import org.osgi.service.converter.Converter;
import org.osgi.service.serializer.Serializing;
public class JsonSerializingImpl implements Serializing {
Modified: felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/yaml/YamlDeserializingImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/yaml/YamlDeserializingImpl.java?rev=1764055&r1=1764054&r2=1764055&view=diff
==============================================================================
--- felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/yaml/YamlDeserializingImpl.java (original)
+++ felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/yaml/YamlDeserializingImpl.java Mon Oct 10 10:55:02 2016
@@ -24,8 +24,8 @@ import java.nio.charset.StandardCharsets
import java.util.Scanner;
import org.apache.felix.converter.impl.Util;
-import org.osgi.service.converter.ConversionException;
-import org.osgi.service.converter.Converter;
+import org.osgi.converter.ConversionException;
+import org.osgi.converter.Converter;
import org.osgi.service.serializer.Deserializing;
import org.yaml.snakeyaml.Yaml;
Modified: felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/yaml/YamlSerializerImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/yaml/YamlSerializerImpl.java?rev=1764055&r1=1764054&r2=1764055&view=diff
==============================================================================
--- felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/yaml/YamlSerializerImpl.java (original)
+++ felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/yaml/YamlSerializerImpl.java Mon Oct 10 10:55:02 2016
@@ -20,9 +20,9 @@ import java.lang.reflect.Type;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import org.osgi.service.converter.Converter;
-import org.osgi.service.converter.StandardConverter;
-import org.osgi.service.converter.TypeReference;
+import org.osgi.converter.Converter;
+import org.osgi.converter.StandardConverter;
+import org.osgi.converter.TypeReference;
import org.osgi.service.serializer.Deserializing;
import org.osgi.service.serializer.Serializer;
import org.osgi.service.serializer.Serializing;
Modified: felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/yaml/YamlSerializingImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/yaml/YamlSerializingImpl.java?rev=1764055&r1=1764054&r2=1764055&view=diff
==============================================================================
--- felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/yaml/YamlSerializingImpl.java (original)
+++ felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/yaml/YamlSerializingImpl.java Mon Oct 10 10:55:02 2016
@@ -28,8 +28,8 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-import org.osgi.service.converter.ConversionException;
-import org.osgi.service.converter.Converter;
+import org.osgi.converter.ConversionException;
+import org.osgi.converter.Converter;
import org.osgi.service.serializer.Serializing;
public class YamlSerializingImpl implements Serializing {
Modified: felix/trunk/converter/serializer/src/main/java/org/osgi/service/serializer/Deserializing.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/serializer/src/main/java/org/osgi/service/serializer/Deserializing.java?rev=1764055&r1=1764054&r2=1764055&view=diff
==============================================================================
--- felix/trunk/converter/serializer/src/main/java/org/osgi/service/serializer/Deserializing.java (original)
+++ felix/trunk/converter/serializer/src/main/java/org/osgi/service/serializer/Deserializing.java Mon Oct 10 10:55:02 2016
@@ -19,7 +19,7 @@ import java.io.InputStream;
import java.nio.charset.Charset;
import org.osgi.annotation.versioning.ProviderType;
-import org.osgi.service.converter.Converter;
+import org.osgi.converter.Converter;
/**
* Interface to specify the source of the decoding operation
@@ -64,24 +64,12 @@ public interface Deserializing<T> {
*/
T from(CharSequence in);
- /**
- * Specify the converter to be used by the code, if an alternative, adapted,
- * converter is to be used.
- *
- * @param converter The converter to use.
- * @return This Deserializing object to allow further invocations on it.
- */
- Deserializing<T> with(Converter converter);
-
/**
- * Provide contextual information to complete the de-serializing operation.
- * The contexts that can be handled are serializer-specific.
+ * Specify the converter to be used by the code, if an alternative, adapted,
+ * converter is to be used.
*
- * @param obj The context to use while deserializing.
- * @return This Deserializing object to allow further invocations on it.
+ * @param converter The converter to use.
+ * @return This Deserializing object to allow further invocations on it.
*/
- default Deserializing<T> withContext(Object obj) {
- // Default or simple deserializers do not need additional context
- return this;
- }
+ Deserializing<T> with(Converter converter);
}
Modified: felix/trunk/converter/serializer/src/main/java/org/osgi/service/serializer/Serializer.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/serializer/src/main/java/org/osgi/service/serializer/Serializer.java?rev=1764055&r1=1764054&r2=1764055&view=diff
==============================================================================
--- felix/trunk/converter/serializer/src/main/java/org/osgi/service/serializer/Serializer.java (original)
+++ felix/trunk/converter/serializer/src/main/java/org/osgi/service/serializer/Serializer.java Mon Oct 10 10:55:02 2016
@@ -18,7 +18,7 @@ package org.osgi.service.serializer;
import java.lang.reflect.Type;
import org.osgi.annotation.versioning.ProviderType;
-import org.osgi.service.converter.TypeReference;
+import org.osgi.converter.TypeReference;
/**
* The Codec service can be used to encode a given object in a certain
@@ -37,8 +37,8 @@ public interface Serializer {
*
* @param <T> The type to decode to.
* @param cls The class to decode to.
- * @return A {@link Deserializing} object to specify the source for the decode
- * operation.
+ * @return A {@link Deserializing} object to specify the source for the
+ * decode operation.
*/
<T> Deserializing<T> deserialize(Class<T> cls);
@@ -47,8 +47,8 @@ public interface Serializer {
*
* @param <T> The type to decode to.
* @param ref A type reference for the target type.
- * @return A {@link Deserializing} object to specify the source for the decode
- * operation.
+ * @return A {@link Deserializing} object to specify the source for the
+ * decode operation.
*/
<T> Deserializing<T> deserialize(TypeReference<T> ref);
@@ -56,8 +56,8 @@ public interface Serializer {
* Start specifying a decode operation.
*
* @param type The type to convert to.
- * @return A {@link Deserializing} object to specify the source for the decode
- * operation.
+ * @return A {@link Deserializing} object to specify the source for the
+ * decode operation.
*/
Deserializing< ? > deserialize(Type type);
Modified: felix/trunk/converter/serializer/src/main/java/org/osgi/service/serializer/Serializing.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/serializer/src/main/java/org/osgi/service/serializer/Serializing.java?rev=1764055&r1=1764054&r2=1764055&view=diff
==============================================================================
--- felix/trunk/converter/serializer/src/main/java/org/osgi/service/serializer/Serializing.java (original)
+++ felix/trunk/converter/serializer/src/main/java/org/osgi/service/serializer/Serializing.java Mon Oct 10 10:55:02 2016
@@ -20,7 +20,7 @@ import java.io.OutputStream;
import java.nio.charset.Charset;
import org.osgi.annotation.versioning.ProviderType;
-import org.osgi.service.converter.Converter;
+import org.osgi.converter.Converter;
/**
* Interface to specify the target of the encoding operation.
@@ -30,79 +30,67 @@ import org.osgi.service.converter.Conver
*/
@ProviderType
public interface Serializing {
- /**
- * Specify that keys with a {@code null} value must not appear in the
- * result. If not specified {@code null} values will be included in the
- * result.
- *
- * @return This Serializing object to allow further invocations on it.
- */
- Serializing ignoreNull();
-
- /**
- * Specify that the encoded output should be formatted to look 'pretty',
- * which may make it easier for humans to read. If not specified, the
- * encoded output should be formatted to be compact, so save space.
- *
- * @return This Serializing object to allow further invocations on it.
- */
- Serializing pretty();
-
- /**
- * Use an output stream as the target of the encoding operation. UTF-8 will
- * be used if applicable, the character set may not apply to binary
- * encodings.
- *
- * @param out The output stream to use.
- * @throws IOException If an I/O error occurred.
- */
- void to(OutputStream out) throws IOException;
-
- /**
- * Use an output stream as the target of the encoding operation.
- *
- * @param out The output stream to use.
- * @param charset The character set to use, if applicable, the character set
- * may not apply to binary encodings.
- * @throws IOException If an I/O error occurred.
- */
- void to(OutputStream out, Charset charset) throws IOException;
-
- /**
- * Encode the object and append the result to an appendable.
- *
- * @param out The appendable object to use.
- * @return The appendable object provided in, which allows further appends
- * to it be done in a fluent programming style.
- */
- Appendable to(Appendable out);
-
- /**
- * Encode the object and return the result as a string.
- *
- * @return The encoded object.
- */
- @Override
- String toString();
+ /**
+ * Specify that keys with a {@code null} value must not appear in the
+ * result. If not specified {@code null} values will be included in the
+ * result.
+ *
+ * @return This Serializing object to allow further invocations on it.
+ */
+ Serializing ignoreNull();
- /**
- * Specify the converter to be used by the code, if an alternative, adapted,
- * converter is to be used.
+ /**
+ * Specify that the encoded output should be formatted to look 'pretty',
+ * which may make it easier for humans to read. If not specified, the
+ * encoded output should be formatted to be compact, so save space.
*
- * @param converter The converter to use.
* @return This Serializing object to allow further invocations on it.
*/
- Serializing with(Converter converter);
+ Serializing pretty();
/**
- * Provide contextual information to complete the serializing operation.
- * The contexts that can be handled are serializer-specific.
+ * Use an output stream as the target of the encoding operation. UTF-8 will
+ * be used if applicable, the character set may not apply to binary
+ * encodings.
*
- * @param obj The context to use while serializing.
+ * @param out The output stream to use.
+ * @throws IOException If an I/O error occurred.
+ */
+ void to(OutputStream out) throws IOException;
+
+ /**
+ * Use an output stream as the target of the encoding operation.
+ *
+ * @param out The output stream to use.
+ * @param charset The character set to use, if applicable, the character set
+ * may not apply to binary encodings.
+ * @throws IOException If an I/O error occurred.
+ */
+ void to(OutputStream out, Charset charset) throws IOException;
+
+ /**
+ * Encode the object and append the result to an appendable.
+ *
+ * @param out The appendable object to use.
+ * @return The appendable object provided in, which allows further appends
+ * to it be done in a fluent programming style.
+ */
+ Appendable to(Appendable out);
+
+ /**
+ * Encode the object and return the result as a string.
+ *
+ * @return The encoded object.
+ */
+ @Override
+ String toString();
+
+ /**
+ * Specify the converter to be used by the code, if an alternative, adapted,
+ * converter is to be used.
+ *
+ * @param converter The converter to use.
* @return This Serializing object to allow further invocations on it.
*/
- default Serializing withContext(Object obj) {
- // Default or simple serializers do not need additional context
- return this;
- }
+ Serializing with(Converter converter);
}