← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20458: use lambda in apps authority provider

 

------------------------------------------------------------
revno: 20458
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-10-02 11:31:15 +0700
message:
  use lambda in apps authority provider
modified:
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/security/authority/AppsSystemAuthoritiesProvider.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-web/dhis-web-commons/src/main/java/org/hisp/dhis/security/authority/AppsSystemAuthoritiesProvider.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/security/authority/AppsSystemAuthoritiesProvider.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/security/authority/AppsSystemAuthoritiesProvider.java	2015-10-02 04:31:15 +0000
@@ -29,13 +29,11 @@
  */
 
 import org.apache.commons.lang3.StringUtils;
-import org.hisp.dhis.appmanager.App;
 import org.hisp.dhis.appmanager.AppManager;
 import org.springframework.beans.factory.annotation.Autowired;
 
-import java.util.ArrayList;
 import java.util.Collection;
-import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -48,16 +46,9 @@
     @Override
     public Collection<String> getSystemAuthorities()
     {
-        List<String> authorities = new ArrayList<>();
-
-        for ( App app : appManager.getApps() )
-        {
-            if ( !StringUtils.isEmpty( app.getName() ) )
-            {
-                authorities.add( "See " + app.getName().trim() );
-            }
-        }
-
-        return authorities;
+        return appManager.getApps().stream()
+            .filter( app -> !StringUtils.isEmpty( app.getName() ) )
+            .map( app -> "See " + app.getName().trim() )
+            .collect( Collectors.toList() );
     }
 }