package love.distributedrebirth.bassboonyd; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import love.distributedrebirth.bassboonyd.info.BãßBȍőnAuthor注; @BãßBȍőnAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天") public interface BãßBȍőnCoffinOpenʸᴰ extends BãßBȍőnCoffinʸᴰ { BãßBȍőnCoffinʸᴰ 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 BãßBȍőnCoffinOpenʸᴰ FROM(BãßBȍőn boon) { return FROM(boon.GET_BBC()); } static BãßBȍőnCoffinOpenʸᴰ FROM(BãßBȍőnCoffinʸᴰ bbc) { return (BãßBȍőnCoffinOpenʸᴰ) bbc; } static class BãßBȍőnFamilyGrave implements BãßBȍőnCoffinGhostʸᴰ { private final Map 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 BãßBȍőnCoffinOpenʸᴰ newInstance() { return new BãßBȍőnCoffinOpenʸᴰ() { private final Map initMap = new HashMap<>(); private final Map,BãßBȍőnFamilyGrave> familyGrave = new HashMap<>(); private volatile boolean deathLock = false; @Override public BãßBȍőnCoffinʸᴰ LOCK_COFFIN() { deathLock = true; //for (BãßBȍőnFamilyGrave grave:familyGrave.values()) { // grave.LOCK_GHOST(); //} return createProxy(); } @Override public Object GET_OBJ(Y key) { return initMap.get(key); } @Override public Object PUT_OBJ(Y key, Object value) { if (deathLock) { throw new IllegalStateException("Can't cheat death in closed coffin."); } return initMap.put(key, value); } @Override public BãßBȍőnCoffinGhostʸᴰ UNHOLY(Class 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ʸᴰ createProxy() { final BãßBȍőnCoffinʸᴰ local = this; /* ClassLoader cl = Thread.currentThread().getContextClassLoader(); if (cl == null) { cl = BãßBȍőnCoffinOpenʸᴰ.class.getClassLoader(); } return (BãßBȍőnCoffinʸᴰ) 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()); Object result = localMethod.invoke(local, args); return result; } }); */ return new BãßBȍőnCoffinʸᴰ() { @Override public BãßBȍőnCoffinGhostʸᴰ UNHOLY(Class familyName) { return local.UNHOLY(familyName); } @Override public Object GET_OBJ(Y key) { return local.GET_OBJ(key); } }; } }; } }