diff --git a/Core/src/main/java/com/songoda/core/configuration/ConfigEntry.java b/Core/src/main/java/com/songoda/core/configuration/ConfigEntry.java index 9e4e8fb6..d3b18b8f 100644 --- a/Core/src/main/java/com/songoda/core/configuration/ConfigEntry.java +++ b/Core/src/main/java/com/songoda/core/configuration/ConfigEntry.java @@ -34,6 +34,9 @@ public interface ConfigEntry { void setDefaultValue(@Nullable Object defaultValue); + @Contract("_ -> this") + ConfigEntry withDefaultValue(@Nullable Object defaultValue); + /** * @see #withComment(Supplier) */ diff --git a/Core/src/main/java/com/songoda/core/configuration/ReadOnlyConfigEntry.java b/Core/src/main/java/com/songoda/core/configuration/ReadOnlyConfigEntry.java index 59cfc50b..2e474ee6 100644 --- a/Core/src/main/java/com/songoda/core/configuration/ReadOnlyConfigEntry.java +++ b/Core/src/main/java/com/songoda/core/configuration/ReadOnlyConfigEntry.java @@ -40,6 +40,12 @@ public class ReadOnlyConfigEntry implements ConfigEntry { throw new UnsupportedOperationException("Cannot set defaultValue on a read-only config entry"); } + @Override + @Contract("_ -> fail") + public ConfigEntry withDefaultValue(@Nullable Object defaultValue) { + throw new UnsupportedOperationException("Cannot set defaultValue on a read-only config entry"); + } + @Override @Contract("_ -> fail") public ConfigEntry withComment(Supplier comment) { diff --git a/Core/src/main/java/com/songoda/core/configuration/yaml/YamlConfigEntry.java b/Core/src/main/java/com/songoda/core/configuration/yaml/YamlConfigEntry.java index d29da1a9..93064e15 100644 --- a/Core/src/main/java/com/songoda/core/configuration/yaml/YamlConfigEntry.java +++ b/Core/src/main/java/com/songoda/core/configuration/yaml/YamlConfigEntry.java @@ -50,6 +50,12 @@ public class YamlConfigEntry implements WriteableConfigEntry { this.defaultValue = defaultValue; } + @Override + public ConfigEntry withDefaultValue(@Nullable Object defaultValue) { + this.setDefaultValue(defaultValue); + return this; + } + @Override public ConfigEntry withUpgradeStep(int version, @Nullable String keyInGivenVersion, @Nullable Function<@Nullable Object, @Nullable Object> valueConverter) { if (keyInGivenVersion == null && valueConverter == null) {