RichDataField extends DataField implements ValueStatusHolder { @Override public Map<?, Integer> getMap(){ if(this.valueMap == null){ this.valueMap = ImmutableMap.copyOf(parseValues()); } return this.valueMap; } RichDataField();  RichDataField(DataField dataField); @Override DataType getDataType(); @Override Map<?, Integer> getMap(); @Override boolean hasValidValues();  }
@Test public void getValueMapping(){ Value invalidValue = createValue("0", Value.Property.INVALID); Value validValueOne = createValue("1", Value.Property.VALID); Value validValueTwo = createValue("2", null); Value validValueThree = createValue("3", null); Value missingValue = createValue("N/A", Value.Property.MISSING); DataField dataField = new DataField(FieldName.create("x"), OpType.CATEGORICAL, DataType.STRING) .addValues(invalidValue, validValueOne, validValueTwo, validValueThree, missingValue); RichDataField richDataField = new RichDataField(dataField); Map<?, Integer> valueMap = richDataField.getMap(); assertEquals(5, valueMap.size()); assertEquals(FieldValue.STATUS_UNKNOWN_INVALID, valueMap.get("0")); assertEquals((Integer)1, valueMap.get("1")); assertEquals((Integer)2, valueMap.get("2")); assertEquals((Integer)3, valueMap.get("3")); assertEquals(FieldValue.STATUS_MISSING, valueMap.get("N/A")); dataField.setDataType(DataType.INTEGER); richDataField = new RichDataField(dataField); valueMap = richDataField.getMap(); assertEquals(4, valueMap.size()); assertEquals(FieldValue.STATUS_UNKNOWN_INVALID, valueMap.get(0)); assertEquals((Integer)1, valueMap.get(1)); assertEquals((Integer)2, valueMap.get(2)); assertEquals((Integer)3, valueMap.get(3)); }