← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20754: minor java 8 update for introspector

 

------------------------------------------------------------
revno: 20754
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-10-19 15:29:13 +0700
message:
  minor java 8 update for introspector
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/AbstractPropertyIntrospectorService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/Jackson2PropertyIntrospectorService.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-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/AbstractPropertyIntrospectorService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/AbstractPropertyIntrospectorService.java	2015-10-09 03:09:03 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/AbstractPropertyIntrospectorService.java	2015-10-19 08:29:13 +0000
@@ -150,7 +150,7 @@
 
                 if ( !joinTableToRoles.containsKey( associatedJoinable.getTableName() ) )
                 {
-                    joinTableToRoles.put( associatedJoinable.getTableName(), new ArrayList<String>() );
+                    joinTableToRoles.put( associatedJoinable.getTableName(), new ArrayList<>() );
                 }
 
                 joinTableToRoles.get( associatedJoinable.getTableName() ).add( collection.getRole() );

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/Jackson2PropertyIntrospectorService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/Jackson2PropertyIntrospectorService.java	2015-09-13 17:45:53 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/Jackson2PropertyIntrospectorService.java	2015-10-19 08:29:13 +0000
@@ -242,7 +242,7 @@
 
     private String getFieldName( Method method )
     {
-        String name = null;
+        String name;
 
         String[] getters = new String[]{
             "is", "has", "get"
@@ -266,23 +266,18 @@
         Map<String, Method> methodMap = ReflectionUtils.getMethodMap( klass );
         List<Property> properties = Lists.newArrayList();
 
-        for ( Method method : methodMap.values() )
-        {
-            if ( method.isAnnotationPresent( JsonProperty.class ) )
-            {
-                if ( method.getGenericParameterTypes().length == 0 )
-                {
-                    String fieldName = getFieldName( method );
-                    String setterName = "set" + StringUtils.capitalize( fieldName );
-
-                    Property property = new Property( klass, method, null );
-                    property.setFieldName( fieldName );
-                    property.setSetterMethod( methodMap.get( setterName ) );
-
-                    properties.add( property );
-                }
-            }
-        }
+        methodMap.values().stream()
+            .filter( method -> method.isAnnotationPresent( JsonProperty.class ) && method.getGenericParameterTypes().length == 0 )
+            .forEach( method -> {
+                String fieldName = getFieldName( method );
+                String setterName = "set" + StringUtils.capitalize( fieldName );
+
+                Property property = new Property( klass, method, null );
+                property.setFieldName( fieldName );
+                property.setSetterMethod( methodMap.get( setterName ) );
+
+                properties.add( property );
+            } );
 
         return properties;
     }