@Test public void putTest() { final String fieldValue2 = "fieldValue-2"; ConfigurationFieldModel configurationFieldModel2 = ConfigurationFieldModel.create(fieldKey); configurationFieldModel2.setFieldValue(fieldValue2); ConfigurationModelMutable configurationModelMutable = createConfigurationModelMutable(); configurationModelMutable.put(configurationFieldModel); configurationModelMutable.put(configurationFieldModel2); Optional<ConfigurationFieldModel> testConfigurationFieldModelOptional = configurationModelMutable.getField(fieldKey); assertTrue(testConfigurationFieldModelOptional.isPresent()); ArrayList<String> fieldValues = new ArrayList<>(testConfigurationFieldModelOptional.get().getFieldValues()); assertEquals(2, fieldValues.size()); assertTrue(fieldValues.contains(fieldValue)); assertTrue(fieldValues.contains(fieldValue2)); }
public void put(ConfigurationFieldModel configFieldModel) { Objects.requireNonNull(configFieldModel); String fieldKey = configFieldModel.getFieldKey(); Objects.requireNonNull(fieldKey); if (getConfiguredFields().containsKey(fieldKey)) { ConfigurationFieldModel oldConfigField = getConfiguredFields().get(fieldKey); List<String> values = combine(oldConfigField, configFieldModel); oldConfigField.setFieldValues(values); } else { getConfiguredFields().put(fieldKey, configFieldModel); } }
ConfigurationModelMutable extends ConfigurationModel { public void put(ConfigurationFieldModel configFieldModel) { Objects.requireNonNull(configFieldModel); String fieldKey = configFieldModel.getFieldKey(); Objects.requireNonNull(fieldKey); if (getConfiguredFields().containsKey(fieldKey)) { ConfigurationFieldModel oldConfigField = getConfiguredFields().get(fieldKey); List<String> values = combine(oldConfigField, configFieldModel); oldConfigField.setFieldValues(values); } else { getConfiguredFields().put(fieldKey, configFieldModel); } } }
ConfigurationModelMutable extends ConfigurationModel { public void put(ConfigurationFieldModel configFieldModel) { Objects.requireNonNull(configFieldModel); String fieldKey = configFieldModel.getFieldKey(); Objects.requireNonNull(fieldKey); if (getConfiguredFields().containsKey(fieldKey)) { ConfigurationFieldModel oldConfigField = getConfiguredFields().get(fieldKey); List<String> values = combine(oldConfigField, configFieldModel); oldConfigField.setFieldValues(values); } else { getConfiguredFields().put(fieldKey, configFieldModel); } } ConfigurationModelMutable(Long registeredDescriptorId, Long descriptorConfigId, String createdAt, String lastUpdated, String context);  ConfigurationModelMutable(Long registeredDescriptorId, Long descriptorConfigId, String createdAt, String lastUpdated, ConfigContextEnum context); }
ConfigurationModelMutable extends ConfigurationModel { public void put(ConfigurationFieldModel configFieldModel) { Objects.requireNonNull(configFieldModel); String fieldKey = configFieldModel.getFieldKey(); Objects.requireNonNull(fieldKey); if (getConfiguredFields().containsKey(fieldKey)) { ConfigurationFieldModel oldConfigField = getConfiguredFields().get(fieldKey); List<String> values = combine(oldConfigField, configFieldModel); oldConfigField.setFieldValues(values); } else { getConfiguredFields().put(fieldKey, configFieldModel); } } ConfigurationModelMutable(Long registeredDescriptorId, Long descriptorConfigId, String createdAt, String lastUpdated, String context);  ConfigurationModelMutable(Long registeredDescriptorId, Long descriptorConfigId, String createdAt, String lastUpdated, ConfigContextEnum context); void put(ConfigurationFieldModel configFieldModel); }
ConfigurationModelMutable extends ConfigurationModel { public void put(ConfigurationFieldModel configFieldModel) { Objects.requireNonNull(configFieldModel); String fieldKey = configFieldModel.getFieldKey(); Objects.requireNonNull(fieldKey); if (getConfiguredFields().containsKey(fieldKey)) { ConfigurationFieldModel oldConfigField = getConfiguredFields().get(fieldKey); List<String> values = combine(oldConfigField, configFieldModel); oldConfigField.setFieldValues(values); } else { getConfiguredFields().put(fieldKey, configFieldModel); } } ConfigurationModelMutable(Long registeredDescriptorId, Long descriptorConfigId, String createdAt, String lastUpdated, String context);  ConfigurationModelMutable(Long registeredDescriptorId, Long descriptorConfigId, String createdAt, String lastUpdated, ConfigContextEnum context); void put(ConfigurationFieldModel configFieldModel);  }