← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12701: minor fix for webutils link generator

 

------------------------------------------------------------
revno: 12701
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-10-16 09:30:34 +0200
message:
  minor fix for webutils link generator
modified:
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ReflectionUtils.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/WebUtils.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ReflectionUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ReflectionUtils.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ReflectionUtils.java	2013-10-16 07:30:34 +0000
@@ -28,6 +28,10 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import org.hisp.dhis.system.util.functional.Function1;
+import org.hisp.dhis.system.util.functional.Predicate;
+import org.springframework.util.StringUtils;
+
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
@@ -42,9 +46,7 @@
 import java.util.List;
 import java.util.Set;
 
-import org.hisp.dhis.system.util.functional.Function1;
-import org.hisp.dhis.system.util.functional.Predicate;
-import org.springframework.util.StringUtils;
+import static org.hisp.dhis.system.util.PredicateUtils.alwaysTrue;
 
 /**
  * @author Lars Helge Overland
@@ -65,7 +67,8 @@
             Method method = object.getClass().getMethod( "getId" );
 
             return (Integer) method.invoke( object );
-        } catch ( Exception ex )
+        }
+        catch ( Exception ex )
         {
             return -1;
         }
@@ -87,7 +90,8 @@
             Method method = object.getClass().getMethod( "get" + property );
 
             return (String) method.invoke( object );
-        } catch ( Exception ex )
+        }
+        catch ( Exception ex )
         {
             return null;
         }
@@ -103,9 +107,9 @@
      */
     public static void setProperty( Object object, String name, String value )
     {
-        Object[] arguments = new Object[] { value };
+        Object[] arguments = new Object[]{ value };
 
-        Class<?>[] parameterTypes = new Class<?>[] { String.class };
+        Class<?>[] parameterTypes = new Class<?>[]{ String.class };
 
         if ( name.length() > 0 )
         {
@@ -116,7 +120,8 @@
                 Method concatMethod = object.getClass().getMethod( name, parameterTypes );
 
                 concatMethod.invoke( object, arguments );
-            } catch ( Exception ex )
+            }
+            catch ( Exception ex )
             {
                 throw new UnsupportedOperationException( "Failed to set property", ex );
             }
@@ -210,7 +215,8 @@
                 }
             }
 
-        } catch ( ClassCastException e )
+        }
+        catch ( ClassCastException e )
         {
             return false;
         }
@@ -220,7 +226,7 @@
 
     public static Method findGetterMethod( String fieldName, Object target )
     {
-        String[] getterNames = new String[] {
+        String[] getterNames = new String[]{
             "get",
             "is",
             "has"
@@ -260,7 +266,7 @@
 
     public static Method findSetterMethod( String fieldName, Object target )
     {
-        String[] setterNames = new String[] {
+        String[] setterNames = new String[]{
             "set"
         };
 
@@ -386,24 +392,24 @@
         return methods;
     }
 
-    @SuppressWarnings( "unchecked" )
+    @SuppressWarnings("unchecked")
     public static <T> T invokeMethod( Object target, Method method, Object... args )
     {
         try
         {
             return (T) method.invoke( target, args );
-        } 
+        }
         catch ( InvocationTargetException e )
         {
             throw new RuntimeException( e );
-        } 
+        }
         catch ( IllegalAccessException e )
         {
             throw new RuntimeException( e );
         }
     }
 
-    @SuppressWarnings( "unchecked" )
+    @SuppressWarnings("unchecked")
     public static <T> T getFieldObject( Field field, T target )
     {
         return (T) invokeGetterMethod( field.getName(), target );
@@ -436,6 +442,11 @@
         }
     }
 
+    public static Collection<Field> collectFields( Class<?> clazz )
+    {
+        return collectFields( clazz, alwaysTrue );
+    }
+
     public static Collection<Field> collectFields( Class<?> clazz, Predicate<Field> predicate )
     {
         Class<?> type = clazz;

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/WebUtils.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/WebUtils.java	2013-10-15 14:57:03 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/WebUtils.java	2013-10-16 07:30:34 +0000
@@ -40,10 +40,9 @@
 import java.lang.reflect.Field;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Date;
 import java.util.List;
 
-import static org.hisp.dhis.system.util.PredicateUtils.*;
+import static org.hisp.dhis.system.util.PredicateUtils.alwaysTrue;
 
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -143,8 +142,7 @@
         }
 
         List<Field> fields = new ArrayList<Field>();
-        fields.addAll( ReflectionUtils.collectFields( object.getClass(), idObjects ) );
-        fields.addAll( ReflectionUtils.collectFields( object.getClass(), idObjectCollections ) );
+        fields.addAll( ReflectionUtils.collectFields( object.getClass() ) );
 
         if ( !deep )
         {