Made DataContainer#getSupplier(Key) private

This commit is contained in:
Rsl1122 2019-02-06 15:40:23 +02:00
parent 3bbca4e8e8
commit 38b33e1051
2 changed files with 4 additions and 6 deletions

View File

@ -73,7 +73,7 @@ public class DataContainer {
map.put(key, new CachingSupplier<>(supplier, timeToLive));
}
public <T> Supplier<T> getSupplier(Key<T> key) {
private <T> Supplier<T> getSupplier(Key<T> key) {
return (Supplier<T>) map.get(key);
}

View File

@ -22,6 +22,7 @@ import org.apache.commons.text.StringSubstitutor;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Objects;
/**
* Formatter for replacing ${placeholder} values inside strings.
@ -31,10 +32,7 @@ import java.util.HashMap;
public class PlaceholderReplacer extends HashMap<String, Serializable> implements Formatter<String> {
public <T> void addPlaceholderFrom(DataContainer container, PlaceholderKey<T> key) {
if (!container.supports(key)) {
return;
}
put(key.getPlaceholder(), container.getSupplier(key).get().toString());
put(key.getPlaceholder(), container.getValue(key).map(Objects::toString).orElse("Missing value " + key.getPlaceholder()));
}
public void addAllPlaceholdersFrom(DataContainer container, PlaceholderKey... keys) {
@ -47,7 +45,7 @@ public class PlaceholderReplacer extends HashMap<String, Serializable> implement
if (!container.supports(key)) {
return;
}
put(key.getPlaceholder(), formatter.apply(container.getSupplier(key).get()));
put(key.getPlaceholder(), container.getFormattedUnsafe(key, formatter));
}
public <T> void addAllPlaceholdersFrom(DataContainer container, Formatter<T> formatter, PlaceholderKey<T>... keys) {