DataValue implements Serializable { public boolean isZero() { return dataElement != null && dataElement.getValueType().isNumeric() && value != null && ZERO_PATTERN.matcher( value ).find(); } DataValue();  DataValue(DataElement dataElement, Period period, OrganisationUnit source,
                     CategoryOptionCombo categoryOptionCombo, CategoryOptionCombo attributeOptionCombo );  DataValue( DataElement dataElement, Period period, OrganisationUnit source,
        CategoryOptionCombo categoryOptionCombo, CategoryOptionCombo attributeOptionCombo, String value );  DataValue( DataElement dataElement, Period period, OrganisationUnit source, CategoryOptionCombo categoryOptionCombo,
        CategoryOptionCombo attributeOptionCombo, String value, String storedBy, Date lastUpdated, String comment ); CategoryOptionCombo getOptionCombo(); boolean isZero(); boolean isNullValue(); boolean isFollowup(); boolean hasComment(); void toggleFollowUp(); void mergeWith( DataValue other ); @Override boolean equals( Object o ); @Override int hashCode(); @Override String toString(); @JsonProperty @JsonSerialize( contentAs = BaseIdentifiableObject.class ) DataElement getDataElement(); void setDataElement( DataElement dataElement ); @JsonProperty Period getPeriod(); void setPeriod( Period period ); @JsonProperty @JsonSerialize( contentAs = BaseIdentifiableObject.class ) OrganisationUnit getSource(); void setSource( OrganisationUnit source ); @JsonProperty @JsonSerialize( contentAs = BaseIdentifiableObject.class ) CategoryOptionCombo getCategoryOptionCombo(); void setCategoryOptionCombo( CategoryOptionCombo categoryOptionCombo ); @JsonProperty String getValue(); CategoryOptionCombo getAttributeOptionCombo(); void setAttributeOptionCombo( CategoryOptionCombo attributeOptionCombo ); void setValue( String value ); String getStoredBy(); void setStoredBy( String storedBy ); Date getCreated(); void setCreated( Date created ); Date getLastUpdated(); void setLastUpdated( Date lastUpdated ); String getComment(); void setComment( String comment ); void setFollowup( Boolean followup ); boolean isDeleted(); void setDeleted( boolean deleted ); String getAuditValue(); static final String TRUE; static final String FALSE; }
@Test public void testIsZero() { DataElement dataElement = new DataElement( "A" ); dataElement.setValueType( ValueType.NUMBER ); DataValue dataValue = new DataValue(); dataValue.setDataElement( dataElement ); dataValue.setValue( "5" ); assertFalse( dataValue.isZero() ); dataValue.setValue( "0.2" ); assertFalse( dataValue.isZero() ); dataValue.setValue( "0.00001" ); assertFalse( dataValue.isZero() ); dataValue.setValue( "String" ); assertFalse( dataValue.isZero() ); dataValue.setValue( "0" ); assertTrue( dataValue.isZero() ); dataValue.setValue( "0.0" ); assertTrue( dataValue.isZero() ); dataValue.setValue( "0.0000" ); assertTrue( dataValue.isZero() ); }