← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18264: Meta data export, using set instead of loop

 

------------------------------------------------------------
revno: 18264
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2015-02-14 18:30:36 +0100
message:
  Meta data export, using set instead of loop
modified:
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultMetaDataDependencyService.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-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultMetaDataDependencyService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultMetaDataDependencyService.java	2015-02-14 12:53:03 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultMetaDataDependencyService.java	2015-02-14 17:30:36 +0000
@@ -29,9 +29,12 @@
  */
 
 import com.fasterxml.jackson.annotation.JsonView;
+import com.google.common.collect.Sets;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.hibernate.proxy.HibernateProxy;
+import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.common.IdentifiableObject;
 import org.hisp.dhis.common.IdentifiableObjectManager;
 import org.hisp.dhis.common.view.ExportView;
@@ -74,7 +77,8 @@
 {
     private static final Log log = LogFactory.getLog( DefaultMetaDataDependencyService.class );
 
-    private final Class<?>[] SPECIAL_CASE_CLASSES = new Class<?>[]{ DataElement.class, DataElementCategoryCombo.class, Indicator.class, OrganisationUnit.class, ValidationRule.class };
+    @SuppressWarnings("unchecked")
+    private final Set<Class<? extends BaseIdentifiableObject>> SPECIAL_CASE_CLASSES = Sets.newHashSet( DataElement.class, DataElementCategoryCombo.class, Indicator.class, OrganisationUnit.class, ValidationRule.class );
 
     //-------------------------------------------------------------------------------------------------------
     // Dependencies
@@ -307,15 +311,7 @@
 
     private boolean isSpecialCase( IdentifiableObject identifiableObject )
     {
-        for ( Class<?> specialCase : SPECIAL_CASE_CLASSES )
-        {
-            if ( identifiableObject.getClass().equals( specialCase ) )
-            {
-                return true;
-            }
-        }
-
-        return false;
+        return SPECIAL_CASE_CLASSES.contains( identifiableObject.getClass() );
     }
 
     private Set<IdentifiableObject> computeSpecialDependencyCase( IdentifiableObject identifiableObject )