forked from SteamWar/SteamWar
Improve YMLWrapper
This commit is contained in:
@@ -99,21 +99,12 @@ public class YMLWrapperImpl<ST> extends YMLWrapper<String, ST, String> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getStringList(String path) {
|
||||
public <T> List<T> get(String path, Function<Object, List<T>> mapper) {
|
||||
Object value = this.document.get(path);
|
||||
if (value instanceof List) {
|
||||
return Collections.unmodifiableList((List<String>) value);
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> getIntList(String path) {
|
||||
Object value = this.document.get(path);
|
||||
if (value instanceof List) {
|
||||
return Collections.unmodifiableList((List<Integer>) value);
|
||||
} else {
|
||||
if (value == null) return Collections.emptyList();
|
||||
try {
|
||||
return Collections.unmodifiableList(mapper.apply(value));
|
||||
} catch (ClassCastException e) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user