mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-04 23:06:05 +00:00
work on metavalue loading
This commit is contained in:
@@ -3,4 +3,7 @@ package com.dfsek.terra.api.config.meta;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public interface MetaValue<T> extends Supplier<T> {
|
||||
static <T1> MetaValue<T1> of(T1 value) {
|
||||
return () -> value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.dfsek.terra.api.util;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class MetaTokenizer {
|
||||
public MetaTokenizer(Reader in) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,12 @@ import com.dfsek.tectonic.exception.LoadException;
|
||||
import com.dfsek.tectonic.loading.ConfigLoader;
|
||||
import com.dfsek.terra.api.config.meta.MetaContext;
|
||||
import com.dfsek.terra.api.config.meta.MetaValue;
|
||||
import com.dfsek.terra.api.util.collections.ProbabilityCollection;
|
||||
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class GenericMetaValueLoader extends MetaValueLoader<MetaValue<Object>, Object> {
|
||||
protected GenericMetaValueLoader(MetaContext context) {
|
||||
@@ -13,8 +17,19 @@ public class GenericMetaValueLoader extends MetaValueLoader<MetaValue<Object>, O
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetaValue<Object> load(Type t, Object c, ConfigLoader loader) throws LoadException {
|
||||
return null;
|
||||
public MetaValue<Object> load(Type type, Object c, ConfigLoader loader) throws LoadException {
|
||||
ProbabilityCollection<Object> collection = new ProbabilityCollection<>();
|
||||
|
||||
if(type instanceof ParameterizedType) {
|
||||
ParameterizedType pType = (ParameterizedType) type;
|
||||
Type generic = pType.getActualTypeArguments()[0];
|
||||
if(c instanceof String) {
|
||||
String possibleMeta = ((String) c).trim();
|
||||
// TODO: parse meta string
|
||||
}
|
||||
|
||||
return MetaValue.of(loader.loadType(generic, c));
|
||||
} else throw new LoadException("Unable to load config! Could not retrieve parameterized type: " + type);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user