@Test public void getFieldValueTest() { String descriptor = "description1"; String context = "context1"; String key = "Key1"; String badKey = "This key doesn't exist"; String testFieldValue = "FieldValue1"; List<String> values = new ArrayList(); values.add(testFieldValue); FieldValueModel newFieldValueModel = new FieldValueModel(values, Boolean.TRUE); Map<String, FieldValueModel> keyToValues = new HashMap<>(); keyToValues.put(key, newFieldValueModel); FieldModel testFieldModel = new FieldModel(descriptor, context, keyToValues); Optional<String> value = testFieldModel.getFieldValue(key); assertEquals(testFieldValue, value.get()); assertTrue(value.isPresent()); value = testFieldModel.getFieldValue(badKey); assertFalse(value.isPresent()); }
public Optional<String> getFieldValue(final String key) { return getFieldValueModel(key).flatMap(FieldValueModel::getValue); }
FieldModel extends Config { public Optional<String> getFieldValue(final String key) { return getFieldValueModel(key).flatMap(FieldValueModel::getValue); } }
FieldModel extends Config { public Optional<String> getFieldValue(final String key) { return getFieldValueModel(key).flatMap(FieldValueModel::getValue); } private  FieldModel();  FieldModel(String descriptorName, String context, Map<String, FieldValueModel> keyToValues);  FieldModel(String configId, String descriptorName, String context, Map<String, FieldValueModel> keyToValues);  FieldModel(String descriptorName, String context, String createdAt, String lastUpdated, Map<String, FieldValueModel> keyToValues);  FieldModel(String configId, String descriptorName, String context, String createdAt, String lastUpdated, Map<String, FieldValueModel> keyToValues); }
FieldModel extends Config { public Optional<String> getFieldValue(final String key) { return getFieldValueModel(key).flatMap(FieldValueModel::getValue); } private  FieldModel();  FieldModel(String descriptorName, String context, Map<String, FieldValueModel> keyToValues);  FieldModel(String configId, String descriptorName, String context, Map<String, FieldValueModel> keyToValues);  FieldModel(String descriptorName, String context, String createdAt, String lastUpdated, Map<String, FieldValueModel> keyToValues);  FieldModel(String configId, String descriptorName, String context, String createdAt, String lastUpdated, Map<String, FieldValueModel> keyToValues); String getDescriptorName(); String getContext(); String getCreatedAt(); String getLastUpdated(); Map<String, FieldValueModel> getKeyToValues(); void setKeyToValues(final Map<String, FieldValueModel> keyToValues); Optional<FieldValueModel> getFieldValueModel(final String key); Optional<String> getFieldValue(final String key); void putField(final String key, final FieldValueModel field); void removeField(final String key); FieldModel fill(final FieldModel fieldModel); }
FieldModel extends Config { public Optional<String> getFieldValue(final String key) { return getFieldValueModel(key).flatMap(FieldValueModel::getValue); } private  FieldModel();  FieldModel(String descriptorName, String context, Map<String, FieldValueModel> keyToValues);  FieldModel(String configId, String descriptorName, String context, Map<String, FieldValueModel> keyToValues);  FieldModel(String descriptorName, String context, String createdAt, String lastUpdated, Map<String, FieldValueModel> keyToValues);  FieldModel(String configId, String descriptorName, String context, String createdAt, String lastUpdated, Map<String, FieldValueModel> keyToValues); String getDescriptorName(); String getContext(); String getCreatedAt(); String getLastUpdated(); Map<String, FieldValueModel> getKeyToValues(); void setKeyToValues(final Map<String, FieldValueModel> keyToValues); Optional<FieldValueModel> getFieldValueModel(final String key); Optional<String> getFieldValue(final String key); void putField(final String key, final FieldValueModel field); void removeField(final String key); FieldModel fill(final FieldModel fieldModel);  }