commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r1612660 - in /commons/proper/configuration/trunk/src: main/java/org/apache/commons/configuration/builder/BuilderConfigurationWrapperFactory.java test/java/org/apache/commons/configuration/builder/TestBuilderConfigurationWrapperFactory.java
Date Tue, 22 Jul 2014 19:56:45 GMT
Author: oheger
Date: Tue Jul 22 19:56:44 2014
New Revision: 1612660

URL: http://svn.apache.org/r1612660
Log:
Simplified BuilderConfigurationWrapperFactory.

Because the methods in configuration builders now have the same return values
as the corresponding event source methods, no conversion of return values is
necessary.

Modified:
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/BuilderConfigurationWrapperFactory.java
    commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/TestBuilderConfigurationWrapperFactory.java

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/BuilderConfigurationWrapperFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/BuilderConfigurationWrapperFactory.java?rev=1612660&r1=1612659&r2=1612660&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/BuilderConfigurationWrapperFactory.java
(original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/BuilderConfigurationWrapperFactory.java
Tue Jul 22 19:56:44 2014
@@ -348,8 +348,7 @@ public class BuilderConfigurationWrapper
                 }
             }
 
-            return convertResult(method.getReturnType(),
-                    methodToInvoke.invoke(target, args));
+            return methodToInvoke.invoke(target, args);
         }
 
         /**
@@ -375,26 +374,5 @@ public class BuilderConfigurationWrapper
                 return null;
             }
         }
-
-        /**
-         * Performs a conversion of the invocation result if necessary. The
-         * {@code removeEventListener()} method of {@code EventSource} returns a
-         * boolean, but the corresponding builder method returns a reference to
-         * the builder for method chaining. So these types have to be adapted.
-         *
-         * @param returnType the expected return type of the current invocation
-         * @param methodResult the actual result returned from the method
-         * @return the converted result
-         */
-        private static Object convertResult(Class<?> returnType,
-                Object methodResult)
-        {
-            if (Boolean.TYPE.equals(returnType)
-                    && !Boolean.class.isInstance(methodResult))
-            {
-                return Boolean.FALSE;
-            }
-            return methodResult;
-        }
     }
 }

Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/TestBuilderConfigurationWrapperFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/TestBuilderConfigurationWrapperFactory.java?rev=1612660&r1=1612659&r2=1612660&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/TestBuilderConfigurationWrapperFactory.java
(original)
+++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/TestBuilderConfigurationWrapperFactory.java
Tue Jul 22 19:56:44 2014
@@ -184,7 +184,12 @@ public class TestBuilderConfigurationWra
 
         src.addEventListener(ConfigurationEvent.ANY, l1);
         src.addEventListener(ConfigurationEvent.ANY_HIERARCHICAL, l2);
-        src.removeEventListener(ConfigurationEvent.ANY_HIERARCHICAL, l2);
+        assertTrue(
+                "Wrong result for existing listener",
+                src.removeEventListener(ConfigurationEvent.ANY_HIERARCHICAL, l2));
+        assertFalse(
+                "Wrong result for non-existing listener",
+                src.removeEventListener(ConfigurationEvent.ANY_HIERARCHICAL, l2));
         PropertiesConfiguration config = builder.getConfiguration();
         Collection<EventListener<? super ConfigurationEvent>> listeners =
                 config.getEventListeners(ConfigurationEvent.ANY_HIERARCHICAL);



Mime
View raw message