gdxapp4d/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboonyd/BãßBȍőnCoffinOpenʸᴰ.java

126 lines
3.8 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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);
}
};
}
};
}
}