mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-19 07:11:14 +00:00
more metaconfig API
This commit is contained in:
@@ -4,5 +4,15 @@ package com.dfsek.terra.api.config.meta;
|
|||||||
* Context from which to pull {@link MetaValue}s
|
* Context from which to pull {@link MetaValue}s
|
||||||
*/
|
*/
|
||||||
public interface MetaContext {
|
public interface MetaContext {
|
||||||
<T> T load(Object metaCandidate);
|
<T> T load(Object in, Class<T> clazz);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load method for when class is unknown.
|
||||||
|
*
|
||||||
|
* @param in Object to load/load metavalue for
|
||||||
|
* @return Loaded object
|
||||||
|
*/
|
||||||
|
default Object load(Object in) {
|
||||||
|
return load(in, in.getClass());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.dfsek.terra.api.config.meta;
|
package com.dfsek.terra.api.config.meta;
|
||||||
|
|
||||||
public interface MetaValue<T> {
|
import java.util.function.Supplier;
|
||||||
T load(MetaContext context);
|
|
||||||
|
public interface MetaValue<T> extends Supplier<T> {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package com.dfsek.terra.api.config.meta.specific.number;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.config.meta.MetaValue;
|
||||||
|
|
||||||
|
public interface MetaNumber<T extends Number> extends MetaValue<T> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.dfsek.terra.config.loaders.meta;
|
||||||
|
|
||||||
|
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 java.lang.reflect.Type;
|
||||||
|
|
||||||
|
public class GenericMetaValueLoader extends MetaValueLoader<MetaValue<Object>, Object> {
|
||||||
|
protected GenericMetaValueLoader(MetaContext context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MetaValue<Object> load(Type t, Object c, ConfigLoader loader) throws LoadException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object get() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,7 +7,7 @@ import com.dfsek.terra.api.config.meta.MetaValue;
|
|||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public abstract class MetaValueLoader<M extends MetaValue<T>, T> implements TypeLoader<M>, Supplier<T> {
|
public abstract class MetaValueLoader<M extends MetaValue<T>, T> implements TypeLoader<M>, Supplier<T> {
|
||||||
private final MetaContext context;
|
protected final MetaContext context;
|
||||||
|
|
||||||
protected MetaValueLoader(MetaContext context) {
|
protected MetaValueLoader(MetaContext context) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
|
|||||||
Reference in New Issue
Block a user