mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-10-26 14:00:14 +00:00
work on metavalue loading
This commit is contained in:
1 parent
f90f7bd063
commit
587cb8755f
3 files changed
+30
-2
No files matched your search
@@ -3,4 +3,7 @@ package com.dfsek.terra.api.config.meta;
|
|||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public interface MetaValue<T> extends Supplier<T> {
|
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) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
+17
-2
@@ -4,8 +4,12 @@ import com.dfsek.tectonic.exception.LoadException;
|
|||||||
import com.dfsek.tectonic.loading.ConfigLoader;
|
import com.dfsek.tectonic.loading.ConfigLoader;
|
||||||
import com.dfsek.terra.api.config.meta.MetaContext;
|
import com.dfsek.terra.api.config.meta.MetaContext;
|
||||||
import com.dfsek.terra.api.config.meta.MetaValue;
|
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.lang.reflect.Type;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class GenericMetaValueLoader extends MetaValueLoader<MetaValue<Object>, Object> {
|
public class GenericMetaValueLoader extends MetaValueLoader<MetaValue<Object>, Object> {
|
||||||
protected GenericMetaValueLoader(MetaContext context) {
|
protected GenericMetaValueLoader(MetaContext context) {
|
||||||
@@ -13,8 +17,19 @@ public class GenericMetaValueLoader extends MetaValueLoader<MetaValue<Object>, O
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MetaValue<Object> load(Type t, Object c, ConfigLoader loader) throws LoadException {
|
public MetaValue<Object> load(Type type, Object c, ConfigLoader loader) throws LoadException {
|
||||||
return null;
|
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
|
@Override
|
||||||
|
|||||||
Reference in new issue
Block a user