mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-10-26 22:10:22 +00:00
make Registry immutable, remove other registry implementations
This commit is contained in:
1 parent
b04a4850da
commit
620ae7d1ff
39 files changed
+275
-819
No files matched your search
+11
-1
@@ -4,15 +4,25 @@ import com.dfsek.terra.addons.manifest.impl.InitInfo;
|
||||
import com.dfsek.terra.api.util.function.Functions;
|
||||
import com.dfsek.terra.api.util.function.monad.Monad;
|
||||
|
||||
import io.vavr.Function0;
|
||||
import io.vavr.Function1;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
|
||||
public class Init<T> implements Monad<T, Init<?>> {
|
||||
private final Function<InitInfo, T> get;
|
||||
|
||||
public static <T> Init<T> of(Function<InitInfo, T> get) {
|
||||
protected static <T> Init<T> of(Function<InitInfo, T> get) {
|
||||
return new Init<>(get);
|
||||
}
|
||||
protected static Init<Void> unit(Consumer<InitInfo> get) {
|
||||
return new Init<>(info -> {
|
||||
get.accept(info);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
private Init(Function<InitInfo, T> get) {
|
||||
this.get = get;
|
||||
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.dfsek.terra.addons.manifest.api.monad;
|
||||
|
||||
import com.dfsek.terra.api.registry.key.Keyed;
|
||||
import com.dfsek.terra.api.util.function.monad.Monad;
|
||||
import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||
|
||||
|
||||
public class Register {
|
||||
private static <T> Monad<Void, Init<?>> register(TypeKey<T> type, String key, T object) {
|
||||
return Init.unit(info -> {
|
||||
throw new UnsupportedOperationException("TODO");
|
||||
});
|
||||
}
|
||||
|
||||
public static <T> Monad<Void, Init<?>> register(Class<T> clazz, String key, T object) {
|
||||
return register(TypeKey.of(clazz), key, object);
|
||||
}
|
||||
|
||||
public static <T extends Keyed<T>> Monad<Void, Init<?>> register(Class<T> clazz, Keyed<T> keyed) {
|
||||
return register(TypeKey.of(clazz), keyed.getID(), keyed.coerce());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user