ConfigurationOption { public static ConfigurationOptionBuilder<String> stringOption() { return new ConfigurationOptionBuilder<String>(StringValueConverter.INSTANCE, String.class); } private  ConfigurationOption(boolean dynamic, boolean sensitive, String key, String label, String description,
								T defaultValue, String configurationCategory, final ValueConverter<T> valueConverter,
								Class<? super T> valueType, List<String> tags, boolean required,
								List<ChangeListener<T>> changeListeners, List<Validator<T>> validators,
								List<String> aliasKeys, final Map<String, String> validOptions); static ConfigurationOptionBuilder<T> builder(ValueConverter<T> valueConverter, Class<? super T> valueType); static ConfigurationOptionBuilder<String> stringOption(); static ConfigurationOptionBuilder<T> jsonOption(TypeReference<T> typeReference, Class<? super T> clazz); static ConfigurationOptionBuilder<Boolean> booleanOption(); static ConfigurationOptionBuilder<Integer> integerOption(); static ConfigurationOptionBuilder<Long> longOption(); static ConfigurationOptionBuilder<Double> doubleOption(); static ConfigurationOptionBuilder<Collection<String>> stringsOption(); static ConfigurationOptionBuilder<Collection<String>> lowerStringsOption(); static ConfigurationOption.ConfigurationOptionBuilder<Collection<Integer>> integersOption(); static ConfigurationOptionBuilder<Collection<Pattern>> regexListOption(); static ConfigurationOptionBuilder<Map<Pattern, String>> regexMapOption(); static ConfigurationOptionBuilder<Map<K, V>> mapOption(ValueConverter<K> keyConverter, ValueConverter<V> valueConverter); static ConfigurationOptionBuilder<T> enumOption(Class<T> clazz); static ConfigurationOptionBuilder<T> serviceLoaderStrategyOption(Class<T> serviceLoaderInterface); static ConfigurationOptionBuilder<URL> urlOption(); static ConfigurationOptionBuilder<List<URL>> urlsOption(); boolean isDynamic(); String getKey(); List<String> getAliasKeys(); String getLabel(); String getDescription(); String getDefaultValueAsString(); String getValueAsString(); String getValueAsSafeString(); boolean isSensitive(); @JsonIgnore T getValue(); @JsonIgnore T get(); @JsonIgnore OptionValue<T> getOptionValue(); String getNameOfCurrentConfigurationSource(); String getConfigurationCategory(); List<String> getTags(); String getValueType(); ValueConverter<T> getValueConverter(); String getErrorMessage(); Collection<String> getValidOptions(); Map<String, String> getValidOptionsLabelMap(); void assertValid(String valueAsString); void update(T newValue, String configurationSourceName); boolean isDefault(); void addChangeListener(ChangeListener<T> changeListener); boolean removeChangeListener(ChangeListener<T> changeListener); String getUsedKey();  }
@Test(expected = IllegalArgumentException.class) public void testDuplicateAlternateKeys() { createConfiguration(Arrays.asList( ConfigurationOption.stringOption().key("primaryKey1").aliasKeys("alternateKey1").build(), ConfigurationOption.stringOption().key("primaryKey2").aliasKeys("alternateKey1").build() ), new SimpleSource()); }
@Test(expected = IllegalArgumentException.class) public void testDefaultValueNull() { ConfigurationOption.stringOption().key("foo").buildWithDefault(null); }
@Test public void testWithOptions_invalidDefault() { assertThatThrownBy(() -> ConfigurationOption.stringOption() .key("test.options") .addValidOptions("foo", "bar") .buildWithDefault("baz")) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("Invalid option"); }
@Test public void testWithOptions_sealedOptions() { assertThatThrownBy(() -> ConfigurationOption.stringOption() .key("test.options") .addValidOptions("foo", "bar") .sealValidOptions() .addValidOption("baz") .buildWithDefault("baz")) .isInstanceOf(IllegalStateException.class) .hasMessage("Options are sealed, you can't add any new ones"); }