Extract decision if setter is skipped

git-svn-id: https://svn.apache.org/repos/asf/aries/trunk/blueprint/blueprint-cm@1657598 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/aries/blueprint/compendium/cm/CmManagedProperties.java b/src/main/java/org/apache/aries/blueprint/compendium/cm/CmManagedProperties.java
index aa01eaf..f7ee03a 100644
--- a/src/main/java/org/apache/aries/blueprint/compendium/cm/CmManagedProperties.java
+++ b/src/main/java/org/apache/aries/blueprint/compendium/cm/CmManagedProperties.java
@@ -213,28 +213,7 @@
                     methods.addAll(Arrays.asList(bean.getClass().getDeclaredMethods()));
                     for (Method method : methods) {
                         if (method.getName().equals(setterName)) {
-                            if (method.getParameterTypes().length == 0) {
-                                LOGGER.debug("Setter takes no parameters: {}", method);
-                                continue;
-                            }
-                            if (method.getParameterTypes().length > 1) {
-                                LOGGER.debug("Setter takes more than one parameter: {}", method);
-                                continue;
-                            }
-                            if (method.getReturnType() != Void.TYPE) {
-                                LOGGER.debug("Setter returns a value: {}", method);
-                                continue;
-                            }
-                            if (Modifier.isAbstract(method.getModifiers())) {
-                                LOGGER.debug("Setter is abstract: {}", method);
-                                continue;
-                            }
-                            if (!Modifier.isPublic(method.getModifiers())) {
-                                LOGGER.debug("Setter is not public: {}", method);
-                                continue;
-                            }
-                            if (Modifier.isStatic(method.getModifiers())) {
-                                LOGGER.debug("Setter is static: {}", method);
+                            if (shouldSkip(method)) {
                                 continue;
                             }
                             Class methodParameterType = method.getParameterTypes()[0];
@@ -284,6 +263,29 @@
         }
     }
 
+    private boolean shouldSkip(Method method) {
+        String msg = null;
+        if (method.getParameterTypes().length == 0) {
+            msg = "takes no parameters";
+        } else if (method.getParameterTypes().length > 1) {
+            msg = "takes more than one parameter";
+        } else if (method.getReturnType() != Void.TYPE) {
+            msg = "returns a value";
+        } else if (Modifier.isAbstract(method.getModifiers())) {
+            msg = "is abstract";
+        } else if (!Modifier.isPublic(method.getModifiers())) {
+            msg = "is not public";
+        } else if (Modifier.isStatic(method.getModifiers())) {
+            msg = "is static";
+        }
+        if (msg != null) {
+            LOGGER.debug("Skipping setter {} because it " + msg, method);
+            return true;
+        } else {
+            return false;
+        }
+    }
+
     private static Throwable getRealCause(Throwable t) {
         if (t instanceof InvocationTargetException && t.getCause() != null) {
             return t.getCause();