← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20692: minor, use lambda in ProgramStage.getAllDataElements

 

------------------------------------------------------------
revno: 20692
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-10-14 14:57:41 +0700
message:
  minor, use lambda in ProgramStage.getAllDataElements
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStage.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-api/src/main/java/org/hisp/dhis/program/ProgramStage.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStage.java	2015-10-07 03:23:23 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStage.java	2015-10-14 07:57:41 +0000
@@ -52,10 +52,10 @@
 import org.hisp.dhis.schema.annotation.PropertyRange;
 import org.hisp.dhis.trackedentity.TrackedEntityInstanceReminder;
 
-import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
+import java.util.stream.Collectors;
 
 /**
  * @author Abyot Asalefew
@@ -143,17 +143,9 @@
 
     public List<DataElement> getAllDataElements()
     {
-        List<DataElement> dataElements = new ArrayList<>();
-
-        for ( ProgramStageDataElement element : programStageDataElements )
-        {
-            if ( element.getDataElement() != null )
-            {
-                dataElements.add( element.getDataElement() );
-            }
-        }
-
-        return dataElements;
+        return programStageDataElements.stream()
+            .filter( element -> element.getDataElement() != null )
+            .map( ProgramStageDataElement::getDataElement ).collect( Collectors.toList() );
     }
 
     @JsonProperty