126 lines
3.7 KiB
Java
126 lines
3.7 KiB
Java
package love.distributedrebirth.bassboonyd;
|
||
|
||
import java.util.ArrayList;
|
||
import java.util.HashMap;
|
||
import java.util.Map;
|
||
|
||
import love.distributedrebirth.bassboonyd.clazz.BãßBȍőnAuthor注;
|
||
import love.distributedrebirth.bassboonyd.sinit.BãßBȍőnꝐŕḯṿª₮ḕ;
|
||
|
||
@BãßBȍőnAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天")
|
||
public interface BãßBȍőnCoffinOpen<T extends BãßBȍőnCoffinNail> extends BãßBȍőnCoffin<T> {
|
||
|
||
BãßBȍőnCoffin<T> LOCK_COFFIN();
|
||
|
||
Object PUT_OBJ(T key, Object value);
|
||
|
||
default void PUT_MAP(T key) {
|
||
PUT_OBJ(key, new HashMap<>());
|
||
}
|
||
|
||
default void PUT_LIST(T key) {
|
||
PUT_OBJ(key, new ArrayList<>());
|
||
}
|
||
|
||
static <X, K extends BãßBȍőnCoffinNail> BãßBȍőnCoffinOpen<K> FROM(BãßBȍőnʸᴰ<X,K> boon) {
|
||
return FROM(boon.toBBC());
|
||
}
|
||
|
||
static <K extends BãßBȍőnCoffinNail> BãßBȍőnCoffinOpen<K> FROM(BãßBȍőnCoffin<K> bbc) {
|
||
return (BãßBȍőnCoffinOpen<K>) bbc;
|
||
}
|
||
|
||
static class BãßBȍőnFamilyGrave implements BãßBȍőnCoffinGhost {
|
||
private final Map<String,Object> ghosts = new HashMap<>();
|
||
//private volatile boolean deathLock = false;
|
||
|
||
//public void LOCK_GHOST() {
|
||
// deathLock = true;
|
||
//}
|
||
|
||
@Override
|
||
public Object PUT_GHOST(String key, Object value) {
|
||
//if (deathLock) {
|
||
// throw new IllegalStateException("Can't restore body of family ghost.");
|
||
//}
|
||
return ghosts.put(key, value);
|
||
}
|
||
|
||
@Override
|
||
public Object GHOST_OBJ(String key) {
|
||
return ghosts.get(key);
|
||
}
|
||
}
|
||
|
||
static <Y extends BãßBȍőnCoffinNail> BãßBȍőnCoffinOpen<Y> newInstance() {
|
||
return new BãßBȍőnCoffinOpen<Y>() {
|
||
private final Map<Y,Object> corpseParts = new HashMap<>();
|
||
private final Map<Class<?>,BãßBȍőnFamilyGrave> familyGrave = new HashMap<>();
|
||
private volatile boolean deathLock = false;
|
||
|
||
@Override
|
||
public BãßBȍőnCoffin<Y> LOCK_COFFIN() {
|
||
deathLock = true;
|
||
//for (BãßBȍőnFamilyGrave grave:familyGrave.values()) {
|
||
// grave.LOCK_GHOST();
|
||
//}
|
||
return createProxy();
|
||
}
|
||
|
||
@Override
|
||
public Object GET_OBJ(Y key) {
|
||
return corpseParts.get(key);
|
||
}
|
||
|
||
@Override
|
||
public Object PUT_OBJ(Y key, Object value) {
|
||
if (deathLock) {
|
||
throw new IllegalStateException("Can't put body parts in closed coffin.");
|
||
}
|
||
return corpseParts.put(key, value);
|
||
}
|
||
|
||
@Override
|
||
public BãßBȍőnCoffinGhost UNHOLY(Class<? extends BãßBȍőnꝐŕḯṿª₮ḕ> familyName) {
|
||
BãßBȍőnFamilyGrave familyGhosts = familyGrave.get(familyName);
|
||
if (familyGhosts == null) {
|
||
//if (deathLock) {
|
||
// throw new IllegalStateException("Can't add more death in closed coffin, its unholy.");
|
||
//}
|
||
familyGhosts = new BãßBȍőnFamilyGrave();
|
||
familyGrave.put(familyName, familyGhosts);
|
||
}
|
||
return familyGhosts;
|
||
}
|
||
|
||
private BãßBȍőnCoffin<Y> createProxy() {
|
||
final BãßBȍőnCoffin<Y> local = this;
|
||
/*
|
||
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
||
if (cl == null) {
|
||
cl = BãßBȍőnCoffinOpenʸᴰ.class.getClassLoader();
|
||
}
|
||
return (BãßBȍőnCoffinʸᴰ<Y>) Proxy.newProxyInstance(cl, new Class[]{BãßBȍőnCoffinʸᴰ.class}, new InvocationHandler() {
|
||
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
||
Method localMethod = local.getClass().getMethod(method.getName(), method.getParameterTypes());
|
||
return localMethod.invoke(local, args);
|
||
}
|
||
});
|
||
*/
|
||
return new BãßBȍőnCoffin<Y>() {
|
||
|
||
@Override
|
||
public BãßBȍőnCoffinGhost UNHOLY(Class<? extends BãßBȍőnꝐŕḯṿª₮ḕ> familyName) {
|
||
return local.UNHOLY(familyName);
|
||
}
|
||
|
||
@Override
|
||
public Object GET_OBJ(Y key) {
|
||
return local.GET_OBJ(key);
|
||
}
|
||
};
|
||
}
|
||
};
|
||
}
|
||
}
|