diff --git a/src/main/java/org/hisp/dhis/model/analytics/MetaDataItem.java b/src/main/java/org/hisp/dhis/model/analytics/MetaDataItem.java index f0cab912..b5a5c6db 100644 --- a/src/main/java/org/hisp/dhis/model/analytics/MetaDataItem.java +++ b/src/main/java/org/hisp/dhis/model/analytics/MetaDataItem.java @@ -27,6 +27,8 @@ */ package org.hisp.dhis.model.analytics; +import static org.apache.commons.lang3.StringUtils.isNotEmpty; + import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import java.io.Serializable; @@ -110,6 +112,16 @@ public boolean isDimensionItemType(DimensionItemType dimensionItemType) { return this.dimensionItemType == dimensionItemType; } + /** + * Indicates whether a name exists. + * + * @return true if a name exists. + */ + @JsonIgnore + public boolean hasName() { + return isNotEmpty(name); + } + /** * Indicates whether an {@link AnalyticsIndicatorType} exists. * diff --git a/src/main/java/org/hisp/dhis/model/dimension/DimensionItem.java b/src/main/java/org/hisp/dhis/model/dimension/DimensionItem.java index 98a3f880..376c9ee4 100644 --- a/src/main/java/org/hisp/dhis/model/dimension/DimensionItem.java +++ b/src/main/java/org/hisp/dhis/model/dimension/DimensionItem.java @@ -77,10 +77,13 @@ public DimensionItemType getDimensionItemType() { /** * Checks if the dimension item is of the given type. * + *

Note that the method uses the get method for dimension item type, as the method may be + * overridden by subclasses. + * * @param type the {@link DimensionItemType}. * @return true if the dimension item is of the given type. */ public boolean isDimensionItemType(DimensionItemType type) { - return this.dimensionItemType == type; + return this.getDimensionItemType() == type; } }