commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brit...@apache.org
Subject svn commit: r1442699 - /commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultBeanProperties.java
Date Tue, 05 Feb 2013 19:08:14 GMT
Author: britter
Date: Tue Feb  5 19:08:14 2013
New Revision: 1442699

URL: http://svn.apache.org/viewvc?rev=1442699&view=rev
Log:
Better to have only one return statement instead of three

Modified:
    commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultBeanProperties.java

Modified: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultBeanProperties.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultBeanProperties.java?rev=1442699&r1=1442698&r2=1442699&view=diff
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultBeanProperties.java
(original)
+++ commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultBeanProperties.java
Tue Feb  5 19:08:14 2013
@@ -64,18 +64,23 @@ final class DefaultBeanProperties<B>
         checkNotNull( propertyName, "Parameter 'propertyName' must not be null!" );
         PropertyDescriptor propertyDescriptor = getPropertyDescriptor( propertyName );
 
+        Method getter;
         if ( propertyDescriptor instanceof IndexedPropertyDescriptor )
         {
             IndexedPropertyDescriptor indexed = (IndexedPropertyDescriptor) propertyDescriptor;
-            return indexed.getIndexedReadMethod() != null ? true : false;
+            getter = indexed.getIndexedReadMethod();
         }
-        if ( propertyDescriptor instanceof MappedPropertyDescriptor )
+        else if ( propertyDescriptor instanceof MappedPropertyDescriptor )
         {
             MappedPropertyDescriptor mapped = (MappedPropertyDescriptor) propertyDescriptor;
-            return mapped.getMappedReadMethod() != null ? true : false;
+            getter = mapped.getMappedReadMethod();
+        }
+        else
+        {
+            getter = propertyDescriptor.getReadMethod();
         }
 
-        return propertyDescriptor.getReadMethod() != null ? true : false;
+        return getter != null ? true : false;
     }
 
     /**
@@ -87,18 +92,23 @@ final class DefaultBeanProperties<B>
         checkNotNull( propertyName, "Parameter 'propertyName' must not be null!" );
         PropertyDescriptor propertyDescriptor = getPropertyDescriptor( propertyName );
 
+        Method setter;
         if ( propertyDescriptor instanceof IndexedPropertyDescriptor )
         {
             IndexedPropertyDescriptor indexed = (IndexedPropertyDescriptor) propertyDescriptor;
-            return indexed.getIndexedWriteMethod() != null ? true : false;
+            setter = indexed.getIndexedWriteMethod();
         }
-        if ( propertyDescriptor instanceof MappedPropertyDescriptor )
+        else if ( propertyDescriptor instanceof MappedPropertyDescriptor )
         {
             MappedPropertyDescriptor mapped = (MappedPropertyDescriptor) propertyDescriptor;
-            return mapped.getMappedWriteMethod() != null ? true : false;
+            setter = mapped.getMappedWriteMethod();
+        }
+        else
+        {
+            setter = propertyDescriptor.getWriteMethod();
         }
 
-        return propertyDescriptor.getWriteMethod() != null ? true : false;
+        return setter != null ? true : false;
     }
 
     /**



Mime
View raw message