singleton range shorthand

This commit is contained in:
dfsek
2021-07-27 20:23:00 -07:00
parent d09fe9b2a4
commit 9d12fe1bf1

View File

@@ -14,7 +14,12 @@ import java.util.Map;
public class RangeLoader implements TypeLoader<Range> {
@Override
public Range load(AnnotatedType type, Object o, ConfigLoader configLoader) throws LoadException {
Map<String, Integer> map = (Map<String, Integer>) o;
return new ConstantRange(map.get("min"), map.get("max"));
if(o instanceof Map) {
Map<String, Integer> map = (Map<String, Integer>) o;
return new ConstantRange(map.get("min"), map.get("max"));
} else {
int h = configLoader.loadType(Integer.class, o);
return new ConstantRange(h, h+1);
}
}
}