felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r1792902 - in /felix/trunk/converter: converter/src/main/java/org/apache/felix/converter/impl/ converter/src/test/java/org/apache/felix/converter/impl/ schematizer/src/main/java/org/apache/felix/schematizer/impl/
Date Thu, 27 Apr 2017 14:19:19 GMT
Author: davidb
Date: Thu Apr 27 14:19:19 2017
New Revision: 1792902

URL: http://svn.apache.org/viewvc?rev=1792902&view=rev
Log:
Felix Converter - update to the changed generics in the OSGi API

Modified:
    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/test/java/org/apache/felix/converter/impl/ConverterBuilderTest.java
    felix/trunk/converter/converter/src/test/java/org/apache/felix/converter/impl/ConverterTest.java
    felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/SchemaBasedConverter.java

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=1792902&r1=1792901&r2=1792902&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 Apr 27 14:19:19 2017
@@ -23,20 +23,20 @@ import java.util.List;
 import java.util.Map;
 
 import org.osgi.util.converter.ConversionException;
-import org.osgi.util.converter.ConverterFunction;
 import org.osgi.util.converter.Converter;
 import org.osgi.util.converter.ConverterBuilder;
+import org.osgi.util.converter.ConverterFunction;
 import org.osgi.util.converter.Converting;
 import org.osgi.util.converter.TypeReference;
 
 public class AdapterImpl implements InternalConverter {
     private final InternalConverter delegate;
-    private final Map<Type, List<ConverterFunction<?>>> typeRules;
-    private final List<ConverterFunction<?>> allRules;
-    private final List<ConverterFunction<?>> errorHandlers;
+    private final Map<Type, List<ConverterFunction>> typeRules;
+    private final List<ConverterFunction> allRules;
+    private final List<ConverterFunction> errorHandlers;
 
-    AdapterImpl(InternalConverter converter, Map<Type, List<ConverterFunction<?>>>
rules,
-            List<ConverterFunction<?>> catchAllRules, List<ConverterFunction<?>>
errHandlers) {
+    AdapterImpl(InternalConverter converter, Map<Type, List<ConverterFunction>>
rules,
+            List<ConverterFunction> catchAllRules, List<ConverterFunction> errHandlers)
{
         delegate = converter;
         typeRules = rules;
         allRules = catchAllRules;
@@ -143,16 +143,16 @@ public class AdapterImpl implements Inte
         @SuppressWarnings("unchecked")
         @Override
         public Object to(Type type) {
-            List<ConverterFunction<?>> tr = typeRules.get(Util.baseType(type));
+            List<ConverterFunction> tr = typeRules.get(Util.baseType(type));
             if (tr == null)
                 tr = Collections.emptyList();
-            List<ConverterFunction<?>> converters = new ArrayList<>(tr.size()
+ allRules.size());
+            List<ConverterFunction> converters = new ArrayList<>(tr.size() +
allRules.size());
             converters.addAll(tr);
             converters.addAll(allRules);
 
             try {
                 if (object != null) {
-                    for (ConverterFunction<?> cf : converters) {
+                    for (ConverterFunction cf : converters) {
                         try {
                             Object res = cf.apply(object, type);
                             if (res != null) {
@@ -169,7 +169,7 @@ public class AdapterImpl implements Inte
 
                 return del.to(type);
             } catch (Exception ex) {
-                for (ConverterFunction<?> eh : errorHandlers) {
+                for (ConverterFunction eh : errorHandlers) {
                     try {
                         Object handled = eh.apply(object, type);
                         if (handled != null)

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=1792902&r1=1792901&r2=1792902&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 Apr 27 14:19:19 2017
@@ -28,9 +28,9 @@ import org.osgi.util.converter.TargetRul
 
 public class ConverterBuilderImpl implements ConverterBuilder {
     private final InternalConverter adapter;
-    private final Map<Type, List<ConverterFunction<?>>> rules = new HashMap<>();
-    private final List<ConverterFunction<?>> catchAllRules = new ArrayList<>();
-    private final List<ConverterFunction<?>> errorHandlers = new ArrayList<>();
+    private final Map<Type, List<ConverterFunction>> rules = new HashMap<>();
+    private final List<ConverterFunction> catchAllRules = new ArrayList<>();
+    private final List<ConverterFunction> errorHandlers = new ArrayList<>();
 
     public ConverterBuilderImpl(InternalConverter a) {
         this.adapter = a;
@@ -42,32 +42,32 @@ public class ConverterBuilderImpl implem
     }
 
     @Override
-    public ConverterBuilder errorHandler(ConverterFunction<Object> func) {
+    public ConverterBuilder errorHandler(ConverterFunction func) {
         errorHandlers.add(func);
         return this;
     }
 
     @Override
-    public ConverterBuilder rule(ConverterFunction<Object> func) {
+    public ConverterBuilder rule(ConverterFunction func) {
     	catchAllRules.add(func);
         return this;
     }
 
     @Override
-    public <T> ConverterBuilder rule(Type t, ConverterFunction<T> func) {
+    public ConverterBuilder rule(Type t, ConverterFunction func) {
     	getRulesList(t).add(func);
     	return this;
     }
 
     @Override
-    public <T> ConverterBuilder rule(TargetRule<T> rule) {
+    public ConverterBuilder rule(TargetRule rule) {
     	Type type = rule.getTargetType();
     	getRulesList(type).add(rule.getFunction());
         return this;
     }
 
-    private List<ConverterFunction<?>> getRulesList(Type type) {
-        List<ConverterFunction<?>> l = rules.get(type);
+    private List<ConverterFunction> getRulesList(Type type) {
+        List<ConverterFunction> l = rules.get(type);
     	if (l == null) {
     		l = new ArrayList<>();
     		rules.put(type, l);

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=1792902&r1=1792901&r2=1792902&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
Thu Apr 27 14:19:19 2017
@@ -31,9 +31,9 @@ import java.util.stream.Stream;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
-import org.osgi.util.converter.ConverterFunction;
 import org.osgi.util.converter.Converter;
 import org.osgi.util.converter.ConverterBuilder;
+import org.osgi.util.converter.ConverterFunction;
 import org.osgi.util.converter.Rule;
 import org.osgi.util.converter.TypeRule;
 import org.osgi.util.function.Function;
@@ -121,7 +121,7 @@ public class ConverterBuilderTest {
 
     @Test
     public void testWildcardAdapter() {
-        ConverterFunction<Object> foo = new ConverterFunction<Object>() {
+        ConverterFunction foo = new ConverterFunction() {
             @Override
             public Object apply(Object obj, Type type) throws Exception {
                 if (!(obj instanceof List))
@@ -148,7 +148,7 @@ public class ConverterBuilderTest {
 
     @Test
     public void testWildcardAdapter1() {
-        ConverterFunction<Object> foo = new ConverterFunction<Object>() {
+        ConverterFunction foo = new ConverterFunction() {
             @Override
             public Object apply(Object obj, Type type) throws Exception {
                 if (!(obj instanceof List))

Modified: felix/trunk/converter/converter/src/test/java/org/apache/felix/converter/impl/ConverterTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/converter/src/test/java/org/apache/felix/converter/impl/ConverterTest.java?rev=1792902&r1=1792901&r2=1792902&view=diff
==============================================================================
--- felix/trunk/converter/converter/src/test/java/org/apache/felix/converter/impl/ConverterTest.java
(original)
+++ felix/trunk/converter/converter/src/test/java/org/apache/felix/converter/impl/ConverterTest.java
Thu Apr 27 14:19:19 2017
@@ -347,7 +347,7 @@ public class ConverterTest {
 
     @Test
     public void testCustomErrorHandling() {
-        ConverterFunction<Object> func = new ConverterFunction<Object>() {
+        ConverterFunction func = new ConverterFunction() {
             @Override
             public Object apply(Object obj, Type targetType) {
                 if ("hello".equals(obj)) {

Modified: felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/SchemaBasedConverter.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/SchemaBasedConverter.java?rev=1792902&r1=1792901&r2=1792902&view=diff
==============================================================================
--- felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/SchemaBasedConverter.java
(original)
+++ felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/SchemaBasedConverter.java
Thu Apr 27 14:19:19 2017
@@ -33,9 +33,10 @@ import org.osgi.util.converter.StandardC
 import org.osgi.util.converter.TargetRule;
 import org.osgi.util.converter.TypeReference;
 
-import static org.apache.felix.schematizer.impl.Util.*;
+import static org.apache.felix.schematizer.impl.Util.asDTO;
+import static org.apache.felix.schematizer.impl.Util.rawClassOf;
 
-public class SchemaBasedConverter<T> implements TargetRule<T> {
+public class SchemaBasedConverter<T> implements TargetRule {
     private final SchemaImpl schema;
     private final Converter converter;
 
@@ -45,7 +46,7 @@ public class SchemaBasedConverter<T> imp
     }
 
     @Override
-    public ConverterFunction<T> getFunction() {
+    public ConverterFunction getFunction() {
         return (obj,t) -> {
             if (!(obj instanceof Map) || schema == null)
                 return handleInvalid();



Mime
View raw message