diff --git a/settings.gradle b/settings.gradle index b2a583b83a..ab970ae39e 100644 --- a/settings.gradle +++ b/settings.gradle @@ -70,7 +70,7 @@ dependencyResolutionManagement { bundle('terminalconsoleappender', ['terminalconsoleappender', 'jline-reader', 'jline-terminal', 'jline-terminal-jna']) // The core of our configuration system, it has many flaws, but it works for the most part - version('night-config', '3.6.4') + version('night-config', '3.6.7') library('night-config-toml', 'com.electronwill.night-config', 'toml').versionRef('night-config') library('night-config-core', 'com.electronwill.night-config', 'core').versionRef('night-config') bundle('night-config', ['night-config-toml', 'night-config-core']) diff --git a/src/main/java/net/minecraftforge/common/ForgeConfigSpec.java b/src/main/java/net/minecraftforge/common/ForgeConfigSpec.java index 513f58c40d..d31e0a055a 100644 --- a/src/main/java/net/minecraftforge/common/ForgeConfigSpec.java +++ b/src/main/java/net/minecraftforge/common/ForgeConfigSpec.java @@ -38,18 +38,16 @@ import com.electronwill.nightconfig.core.UnmodifiableConfig; import com.electronwill.nightconfig.core.file.FileConfig; import com.electronwill.nightconfig.core.utils.UnmodifiableConfigWrapper; import com.google.common.base.Joiner; -import com.google.common.base.Preconditions; import com.google.common.base.Splitter; -import com.google.common.collect.Lists; import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.Nullable; -/* +/** * Like {@link com.electronwill.nightconfig.core.ConfigSpec} except in builder format, and extended to accept comments, language keys, * and other things Forge configs would find useful. */ -public class ForgeConfigSpec extends UnmodifiableConfigWrapper implements IConfigSpec//TODO: Remove extends and pipe everything through getSpec/getValues? -{ +//TODO: Remove extends and pipe everything through getSpec/getValues? +public class ForgeConfigSpec extends UnmodifiableConfigWrapper implements IConfigSpec { private final Map, String> levelComments; private final Map, String> levelTranslationKeys; @@ -60,6 +58,9 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper, String> levelComments, Map, String> levelTranslationKeys) { super(storage); @@ -87,8 +88,8 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper LOGGER.debug(Logging.CORE, "The comment on key {} does not match the spec. This may create a backup.", DOT_JOINER.join( path ))); - if (config instanceof FileConfig) { - ((FileConfig) config).save(); + if (config instanceof FileConfig fileConfig) { + fileConfig.save(); } } this.afterReload(); @@ -99,6 +100,7 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper parentPath = new LinkedList<>(); return correct(this.config, config, parentPath, Collections.unmodifiableList( parentPath ), (a, b, c, d) -> {}, null, true) == 0; } + @Override public int correct(CommentedConfig config) { return correct(config, (action, path, incorrectValue, correctedValue) -> {}, null); } @@ -162,15 +166,13 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper parentPath, List parentPathUnmodifiable, CorrectionListener listener, CorrectionListener commentListener, boolean dryRun) - { + private int correct(UnmodifiableConfig spec, CommentedConfig config, LinkedList parentPath, List parentPathUnmodifiable, CorrectionListener listener, CorrectionListener commentListener, boolean dryRun) { int count = 0; Map specMap = spec.valueMap(); Map configMap = config.valueMap(); - for (Map.Entry specEntry : specMap.entrySet()) - { + for (Map.Entry specEntry : specMap.entrySet()) { final String key = specEntry.getKey(); final Object specValue = specEntry.getValue(); final Object configValue = configMap.get(key); @@ -178,20 +180,14 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper 0 && dryRun) return count; - } - else if (dryRun) - { + } else if (dryRun) { return 1; - } - else - { + } else { CommentedConfig newValue = config.createSubConfig(); configMap.put(key, newValue); listener.onCorrect(action, parentPathUnmodifiable, configValue, newValue); @@ -199,10 +195,9 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper> ittr = configMap.entrySet().iterator(); ittr.hasNext();) - { + for (Iterator> ittr = configMap.entrySet().iterator(); ittr.hasNext();) { Map.Entry entry = ittr.next(); - if (!specMap.containsKey(entry.getKey())) - { + if (!specMap.containsKey(entry.getKey())) { if (dryRun) return 1; @@ -260,23 +249,19 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper, String> levelComments = new HashMap<>(); @@ -284,7 +269,7 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper currentPath = new ArrayList<>(); private final List> values = new ArrayList<>(); - //Object + //region Objects public ConfigValue define(String path, T defaultValue) { return define(split(path), defaultValue); } @@ -310,8 +295,7 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper ConfigValue define(List path, ValueSpec value, Supplier defaultSupplier) { // This is the root where everything at the end of the day ends up. if (!currentPath.isEmpty()) { - List tmp = new ArrayList<>(currentPath.size() + path.size()); - tmp.addAll(currentPath); + List tmp = new ArrayList<>(currentPath); tmp.addAll(path); path = tmp; } @@ -331,7 +315,7 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper> ConfigValue defineInRange(List path, Supplier defaultSupplier, V min, V max, Class clazz) { Range range = new Range<>(clazz, min, max); context.setRange(range); - comment("Range: " + range.toString()); + comment("Range: " + range); if (min.compareTo(max) > 0) throw new IllegalArgumentException("Range min most be less then max."); return define(path, defaultSupplier, range); @@ -348,6 +332,9 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper ConfigValue defineInList(List path, Supplier defaultSupplier, Collection acceptableValues) { return define(path, defaultSupplier, acceptableValues::contains); } + //endregion + + //region Collections public ConfigValue> defineList(String path, List defaultValue, Predicate elementValidator) { return defineList(split(path), defaultValue, elementValidator); } @@ -362,17 +349,17 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper x instanceof List && ((List) x).stream().allMatch( elementValidator ), context, path) { @Override public Object correct(Object value) { - if (value == null || !(value instanceof List) || ((List)value).isEmpty()) { + if (!(value instanceof List list) || list.isEmpty()) { LOGGER.debug(Logging.CORE, "List on key {} is deemed to need correction. It is null, not a list, or an empty list. Modders, consider defineListAllowEmpty?", path.get(path.size() - 1)); return getDefault(); } - List list = new ArrayList<>((List) value); - list.removeIf(elementValidator.negate()); - if (list.isEmpty()) { + final List copy = new ArrayList<>(list); + copy.removeIf(elementValidator.negate()); + if (copy.isEmpty()) { LOGGER.debug(Logging.CORE, "List on key {} is deemed to need correction. It failed validation.", path.get(path.size() - 1)); return getDefault(); } - return list; + return copy; } }, defaultSupplier); } @@ -390,22 +377,23 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper x instanceof List && ((List) x).stream().allMatch( elementValidator ), context, path) { @Override public Object correct(Object value) { - if (value == null || !(value instanceof List)) { + if (!(value instanceof List list)) { LOGGER.debug(Logging.CORE, "List on key {} is deemed to need correction, as it is null or not a list.", path.get(path.size() - 1)); return getDefault(); } - List list = new ArrayList<>((List) value); - list.removeIf(elementValidator.negate()); - if (list.isEmpty()) { + final List copy = new ArrayList<>(list); + copy.removeIf(elementValidator.negate()); + if (copy.isEmpty()) { LOGGER.debug(Logging.CORE, "List on key {} is deemed to need correction. It failed validation.", path.get(path.size() - 1)); return getDefault(); } - return list; + return copy; } }, defaultSupplier); } + //endregion - //Enum + //region Enums public > EnumValue defineEnum(String path, V defaultValue) { return defineEnum(split(path), defaultValue); } @@ -428,7 +416,7 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper> EnumValue defineEnum(List path, V defaultValue, V... acceptableValues) { - return defineEnum(path, defaultValue, (Collection) Arrays.asList(acceptableValues)); + return defineEnum(path, defaultValue, Arrays.asList(acceptableValues)); } @SuppressWarnings("unchecked") public > EnumValue defineEnum(List path, V defaultValue, EnumGetMethod converter, V... acceptableValues) { @@ -445,12 +433,12 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper> EnumValue defineEnum(List path, V defaultValue, EnumGetMethod converter, Collection acceptableValues) { return defineEnum(path, defaultValue, converter, obj -> { - if (obj instanceof Enum) { - return acceptableValues.contains(obj); - } if (obj == null) { return false; } + if (obj instanceof Enum) { + return acceptableValues.contains(obj); + } try { return acceptableValues.contains(converter.get(obj, defaultValue.getDeclaringClass())); } catch (IllegalArgumentException | ClassCastException e) { @@ -483,32 +471,49 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper(this, define(path, new ValueSpec(defaultSupplier, validator, context, path), defaultSupplier).getPath(), defaultSupplier, converter, clazz); + return new EnumValue<>(this, define(path, new ValueSpec(defaultSupplier, validator, context, path), defaultSupplier).getPath(), defaultSupplier, converter, clazz); } + //endregion - //boolean + //region booleans public BooleanValue define(String path, boolean defaultValue) { return define(split(path), defaultValue); } public BooleanValue define(List path, boolean defaultValue) { - return define(path, (Supplier)() -> defaultValue); + return define(path, () -> defaultValue); } public BooleanValue define(String path, Supplier defaultSupplier) { return define(split(path), defaultSupplier); } public BooleanValue define(List path, Supplier defaultSupplier) { return new BooleanValue(this, define(path, defaultSupplier, o -> { - if (o instanceof String) return ((String)o).equalsIgnoreCase("true") || ((String)o).equalsIgnoreCase("false"); + if (o instanceof String s) return s.equalsIgnoreCase("true") || s.equalsIgnoreCase("false"); return o instanceof Boolean; }, Boolean.class).getPath(), defaultSupplier); } + //endregion - //Double + //region floats + public FloatValue defineInRange(String path, float defaultValue, float min, float max) { + return defineInRange(split(path), defaultValue, min, max); + } + public FloatValue defineInRange(List path, float defaultValue, float min, float max) { + return defineInRange(path, () -> defaultValue, min, max); + } + public FloatValue defineInRange(String path, Supplier defaultSupplier, float min, float max) { + return defineInRange(split(path), defaultSupplier, min, max); + } + public FloatValue defineInRange(List path, Supplier defaultSupplier, float min, float max) { + return new FloatValue(this, defineInRange(path, defaultSupplier, min, max, Float.class).getPath(), defaultSupplier); + } + //endregion + + //region doubles public DoubleValue defineInRange(String path, double defaultValue, double min, double max) { return defineInRange(split(path), defaultValue, min, max); } public DoubleValue defineInRange(List path, double defaultValue, double min, double max) { - return defineInRange(path, (Supplier)() -> defaultValue, min, max); + return defineInRange(path, () -> defaultValue, min, max); } public DoubleValue defineInRange(String path, Supplier defaultSupplier, double min, double max) { return defineInRange(split(path), defaultSupplier, min, max); @@ -516,13 +521,44 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper path, Supplier defaultSupplier, double min, double max) { return new DoubleValue(this, defineInRange(path, defaultSupplier, min, max, Double.class).getPath(), defaultSupplier); } + //endregion - //Ints + //region bytes + public ByteValue defineInRange(String path, byte defaultValue, byte min, byte max) { + return defineInRange(split(path), defaultValue, min, max); + } + public ByteValue defineInRange(List path, byte defaultValue, byte min, byte max) { + return defineInRange(path, () -> defaultValue, min, max); + } + public ByteValue defineInRange(String path, Supplier defaultSupplier, byte min, byte max) { + return defineInRange(split(path), defaultSupplier, min, max); + } + public ByteValue defineInRange(List path, Supplier defaultSupplier, byte min, byte max) { + return new ByteValue(this, defineInRange(path, defaultSupplier, min, max, Byte.class).getPath(), defaultSupplier); + } + //endregion + + //region shorts + public ShortValue defineInRange(String path, short defaultValue, short min, short max) { + return defineInRange(split(path), defaultValue, min, max); + } + public ShortValue defineInRange(List path, short defaultValue, short min, short max) { + return defineInRange(path, () -> defaultValue, min, max); + } + public ShortValue defineInRange(String path, Supplier defaultSupplier, short min, short max) { + return defineInRange(split(path), defaultSupplier, min, max); + } + public ShortValue defineInRange(List path, Supplier defaultSupplier, short min, short max) { + return new ShortValue(this, defineInRange(path, defaultSupplier, min, max, Short.class).getPath(), defaultSupplier); + } + //endregion + + //region ints public IntValue defineInRange(String path, int defaultValue, int min, int max) { return defineInRange(split(path), defaultValue, min, max); } public IntValue defineInRange(List path, int defaultValue, int min, int max) { - return defineInRange(path, (Supplier)() -> defaultValue, min, max); + return defineInRange(path, () -> defaultValue, min, max); } public IntValue defineInRange(String path, Supplier defaultSupplier, int min, int max) { return defineInRange(split(path), defaultSupplier, min, max); @@ -530,13 +566,14 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper path, Supplier defaultSupplier, int min, int max) { return new IntValue(this, defineInRange(path, defaultSupplier, min, max, Integer.class).getPath(), defaultSupplier); } + //endregion - //Longs + //region longs public LongValue defineInRange(String path, long defaultValue, long min, long max) { return defineInRange(split(path), defaultValue, min, max); } public LongValue defineInRange(List path, long defaultValue, long min, long max) { - return defineInRange(path, (Supplier)() -> defaultValue, min, max); + return defineInRange(path, () -> defaultValue, min, max); } public LongValue defineInRange(String path, Supplier defaultSupplier, long min, long max) { return defineInRange(split(path), defaultSupplier, min, max); @@ -544,18 +581,17 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper path, Supplier defaultSupplier, long min, long max) { return new LongValue(this, defineInRange(path, defaultSupplier, min, max, Long.class).getPath(), defaultSupplier); } + //endregion - public Builder comment(String comment) - { + public Builder comment(String comment) { context.addComment(comment); return this; } - public Builder comment(String... comment) - { + public Builder comment(String... comment) { // Iterate list first, to throw meaningful errors // Don't add any comments until we make sure there is no nulls for (int i = 0; i < comment.length; i++) - Preconditions.checkNotNull(comment[i], "Comment string at " + i + " is null."); + Objects.requireNonNull(comment[i], "Comment string at " + i + " is null."); for (String s : comment) context.addComment(s); @@ -563,14 +599,12 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper(currentPath), context.getTranslationKey()); + levelTranslationKeys.put(new ArrayList<>(currentPath), context.getTranslationKey()); context.setTranslationKey(null); } context.ensureEmpty(); @@ -610,8 +644,7 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper valueCfg.set(v.getPath(), v)); @@ -626,29 +659,24 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper comment = new LinkedList<>(); private String langKey; private Range range; private boolean worldRestart = false; private Class clazz; - public void addComment(String value) - { - // Don't use `validate` because it throws IllegalStateException, not NullPointerException - Preconditions.checkNotNull(value, "Passed in null value for comment"); + public void addComment(String value) { + Objects.requireNonNull(value, "Passed in null value for comment"); comment.add(value); } public void clearComment() { comment.clear(); } - public boolean hasComment() { return this.comment.size() > 0; } + public boolean hasComment() { return !this.comment.isEmpty(); } public String buildComment() { return buildComment(List.of("unknown", "unknown")); } - public String buildComment(final List path) - { - if (comment.stream().allMatch(String::isBlank)) - { + public String buildComment(final List path) { + if (comment.stream().allMatch(String::isBlank)) { if (FMLEnvironment.production) LOGGER.warn(Logging.CORE, "Detected a comment that is all whitespace for config option {}, which causes obscure bugs in Forge's config system and will cause a crash in the future. Please report this to the mod author.", DOT_JOINER.join(path)); @@ -662,8 +690,7 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper> void setRange(Range value) - { + public > void setRange(Range value) { this.range = value; this.setClazz(value.getClazz()); } @@ -674,35 +701,30 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper clazz) { this.clazz = clazz; } public Class getClazz(){ return this.clazz; } - public void ensureEmpty() - { + public void ensureEmpty() { validate(hasComment(), "Non-empty comment when empty expected"); validate(langKey, "Non-null translation key when null expected"); validate(range, "Non-null range when null expected"); validate(worldRestart, "Dangeling world restart value set to true"); } - private void validate(Object value, String message) - { + private void validate(Object value, String message) { if (value != null) throw new IllegalStateException(message); } - private void validate(boolean value, String message) - { + private void validate(boolean value, String message) { if (value) throw new IllegalStateException(message); } } @SuppressWarnings("unused") - public static class Range> implements Predicate - { + public static class Range> implements Predicate { private final Class clazz; private final V min; private final V max; - private Range(Class clazz, V min, V max) - { + private Range(Class clazz, V min, V max) { this.clazz = clazz; this.min = min; this.max = max; @@ -712,20 +734,16 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper= 0 && c.compareTo(max) <= 0; - if(!result) - { + if(!result) { LOGGER.debug(Logging.CORE, "Range value {} is not within its bounds {}-{}", c, min, max); } return result; } - public Object correct(Object value, Object def) - { - if (isNumber(value)) - { + public Object correct(Object value, Object def) { + if (isNumber(value)) { Number n = (Number) value; return n.doubleValue() < ((Number)min).doubleValue() ? min : n.doubleValue() > ((Number)max).doubleValue() ? max : value; } @@ -754,8 +769,7 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper " + min; @@ -767,8 +781,7 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper range; @@ -777,8 +790,7 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper supplier; private final Predicate validator; - private ValueSpec(Supplier supplier, Predicate validator, BuilderContext context, List path) - { + private ValueSpec(Supplier supplier, Predicate validator, BuilderContext context, List path) { Objects.requireNonNull(supplier, "Default supplier can not be null"); Objects.requireNonNull(validator, "Validator can not be null"); @@ -803,9 +815,8 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper implements Supplier - { - private static boolean USE_CACHES = true; + public static class ConfigValue implements Supplier { + private static final boolean USE_CACHES = true; private final Builder parent; private final List path; @@ -823,8 +834,7 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper getPath() - { + public List getPath() { return new ArrayList<>(path); } @@ -837,19 +847,19 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper path, Supplier defaultSupplier) - { + protected T getRaw(Config config, List path, Supplier defaultSupplier) { return config.getOrElse(path, defaultSupplier); } /** * {@return the default value for the configuration setting} */ - public T getDefault() - { + public T getDefault() { return defaultSupplier.get(); } - public Builder next() - { + public Builder next() { return parent; } - public void save() - { - Preconditions.checkNotNull(spec, "Cannot save config value before spec is built"); - Preconditions.checkNotNull(spec.childConfig, "Cannot save config value without assigned Config object present"); + public void save() { + Objects.requireNonNull(spec, "Cannot save config value before spec is built"); + Objects.requireNonNull(spec.childConfig, "Cannot save config value without assigned Config object present"); spec.save(); } - public void set(T value) - { - Preconditions.checkNotNull(spec, "Cannot set config value before spec is built"); - Preconditions.checkNotNull(spec.childConfig, "Cannot set config value without assigned Config object present"); + public void set(T value) { + Objects.requireNonNull(spec, "Cannot set config value before spec is built"); + Objects.requireNonNull(spec.childConfig, "Cannot set config value without assigned Config object present"); spec.childConfig.set(path, value); this.cachedValue = value; } @@ -901,81 +906,97 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper - { - BooleanValue(Builder parent, List path, Supplier defaultSupplier) - { + public static class BooleanValue extends ConfigValue { + BooleanValue(Builder parent, List path, Supplier defaultSupplier) { super(parent, path, defaultSupplier); } } - public static class IntValue extends ConfigValue - { - IntValue(Builder parent, List path, Supplier defaultSupplier) - { + public static class ByteValue extends ConfigValue { + ByteValue(Builder parent, List path, Supplier defaultSupplier) { super(parent, path, defaultSupplier); } @Override - protected Integer getRaw(Config config, List path, Supplier defaultSupplier) - { - return config.getIntOrElse(path, () -> defaultSupplier.get()); + protected Byte getRaw(Config config, List path, Supplier defaultSupplier) { + return config.getByteOrElse(path, defaultSupplier.get()); } } - public static class LongValue extends ConfigValue - { - LongValue(Builder parent, List path, Supplier defaultSupplier) - { + public static class ShortValue extends ConfigValue { + ShortValue(Builder parent, List path, Supplier defaultSupplier) { super(parent, path, defaultSupplier); } @Override - protected Long getRaw(Config config, List path, Supplier defaultSupplier) - { - return config.getLongOrElse(path, () -> defaultSupplier.get()); + protected Short getRaw(Config config, List path, Supplier defaultSupplier) { + return config.getShortOrElse(path, defaultSupplier.get()); } } - public static class DoubleValue extends ConfigValue - { - DoubleValue(Builder parent, List path, Supplier defaultSupplier) - { + public static class IntValue extends ConfigValue { + IntValue(Builder parent, List path, Supplier defaultSupplier) { super(parent, path, defaultSupplier); } @Override - protected Double getRaw(Config config, List path, Supplier defaultSupplier) - { - Number n = config.get(path); + protected Integer getRaw(Config config, List path, Supplier defaultSupplier) { + return config.getIntOrElse(path, defaultSupplier::get); + } + } + + public static class LongValue extends ConfigValue { + LongValue(Builder parent, List path, Supplier defaultSupplier) { + super(parent, path, defaultSupplier); + } + + @Override + protected Long getRaw(Config config, List path, Supplier defaultSupplier) { + return config.getLongOrElse(path, defaultSupplier::get); + } + } + + public static class FloatValue extends ConfigValue { + FloatValue(Builder parent, List path, Supplier defaultSupplier) { + super(parent, path, defaultSupplier); + } + + @Override + protected Float getRaw(Config config, List path, Supplier defaultSupplier) { + Number n = config.get(path); + return n == null ? defaultSupplier.get() : n.floatValue(); + } + } + + public static class DoubleValue extends ConfigValue { + DoubleValue(Builder parent, List path, Supplier defaultSupplier) { + super(parent, path, defaultSupplier); + } + + @Override + protected Double getRaw(Config config, List path, Supplier defaultSupplier) { + Number n = config.get(path); return n == null ? defaultSupplier.get() : n.doubleValue(); } } - public static class EnumValue> extends ConfigValue - { + public static class EnumValue> extends ConfigValue { private final EnumGetMethod converter; private final Class clazz; - EnumValue(Builder parent, List path, Supplier defaultSupplier, EnumGetMethod converter, Class clazz) - { + EnumValue(Builder parent, List path, Supplier defaultSupplier, EnumGetMethod converter, Class clazz) { super(parent, path, defaultSupplier); this.converter = converter; this.clazz = clazz; } @Override - protected T getRaw(Config config, List path, Supplier defaultSupplier) - { + protected T getRaw(Config config, List path, Supplier defaultSupplier) { return config.getEnumOrElse(path, clazz, converter, defaultSupplier); } } - private static final Joiner LINE_JOINER = Joiner.on("\n"); - private static final Joiner DOT_JOINER = Joiner.on("."); - private static final Splitter DOT_SPLITTER = Splitter.on("."); - private static List split(String path) - { - return Lists.newArrayList(DOT_SPLITTER.split(path)); + private static List split(String path) { + return DOT_SPLITTER.splitToStream(path).toList(); } }