dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #41938
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21405: ExpressionService. Returning empty collections instead of null.
------------------------------------------------------------
revno: 21405
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-12-10 12:41:13 +0100
message:
ExpressionService. Returning empty collections instead of null.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/ExpressionService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.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/expression/ExpressionService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/ExpressionService.java 2015-12-10 11:32:45 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/ExpressionService.java 2015-12-10 11:41:13 +0000
@@ -179,7 +179,8 @@
Map<String, Double> constantMap, Map<String, Integer> orgUnitCountMap, Integer days, Set<DataElementOperand> incompleteValues );
/**
- * Returns all data elements included in the given expression string.
+ * Returns all data elements included in the given expression string. Returns
+ * an empty set if the given expression is null.
*
* @param expression the expression string.
* @return a set of data elements included in the expression string.
@@ -188,7 +189,7 @@
/**
* Returns all OrganisationUnitGroups in the numerator and denominator
- * expressions in the given Indicators. Returns an empty list if the given
+ * expressions in the given Indicators. Returns an empty set if the given
* indicators are null or empty.
*
* @param indicators the set of indicators.
@@ -198,7 +199,7 @@
/**
* Returns all OrganisationUnitGroups in the given expression string. Returns
- * an empty list if the given indicators are null or empty.
+ * an set list if the given indicators are null or empty.
*
* @param expression the expression string.
* @return a Set of OrganisationUnitGroups included in the expression string.
@@ -207,7 +208,8 @@
/**
* Returns all CategoryOptionCombos in the given expression string. Only
- * operands with a category option combo will be included.
+ * operands with a category option combo will be included. Returns an empty
+ * set if the given expression is null.
*
* @param expression the expression string.
* @return a Set of CategoryOptionCombos included in the expression string.
@@ -218,7 +220,8 @@
* Returns all operands included in an expression string. The operand is on
* the form #{data-element-id.category-option combo-id}. Only operands with
* a category option combo will be included. Requires that the expression
- * has been exploded in order to handle data element totals.
+ * has been exploded in order to handle data element totals. Returns an
+ * empty set if the given expression is null.
*
* @param expression The expression string.
* @return A Set of Operands.
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java 2015-12-10 11:32:45 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java 2015-12-10 11:41:13 +0000
@@ -252,12 +252,10 @@
private Set<DataElement> getDataElementsInExpressionInternal( Pattern pattern, String expression )
{
- Set<DataElement> dataElements = null;
+ Set<DataElement> dataElements = new HashSet<>();;
if ( expression != null )
{
- dataElements = new HashSet<>();
-
final Matcher matcher = pattern.matcher( expression );
while ( matcher.find() )
@@ -318,12 +316,10 @@
@Transactional
public Set<DataElementCategoryOptionCombo> getOptionCombosInExpression( String expression )
{
- Set<DataElementCategoryOptionCombo> optionCombosInExpression = null;
+ Set<DataElementCategoryOptionCombo> optionCombosInExpression = new HashSet<>();
if ( expression != null )
{
- optionCombosInExpression = new HashSet<>();
-
final Matcher matcher = OPTION_COMBO_OPERAND_PATTERN.matcher( expression );
while ( matcher.find() )
@@ -345,12 +341,10 @@
@Transactional
public Set<DataElementOperand> getOperandsInExpression( String expression )
{
- Set<DataElementOperand> operandsInExpression = null;
+ Set<DataElementOperand> operandsInExpression = new HashSet<>();
if ( expression != null )
{
- operandsInExpression = new HashSet<>();
-
final Matcher matcher = OPTION_COMBO_OPERAND_PATTERN.matcher( expression );
while ( matcher.find() )