2022-02-02 16:34:46 +00:00
|
|
|
package love.distributedrebirth.bassboonyd;
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.Map;
|
2022-02-13 12:24:02 +00:00
|
|
|
import java.util.function.Consumer;
|
2022-02-02 16:34:46 +00:00
|
|
|
|
2022-02-02 17:01:10 +00:00
|
|
|
@BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天")
|
2022-02-06 16:19:05 +00:00
|
|
|
public interface BãßBȍőnCoffinOpenʸᴰ<T extends BãßBȍőnCoffinStoreKeyʸᴰ> extends BãßBȍőnCoffinʸᴰ<T>, DefaultInitMethodʸᴰ {
|
2022-02-02 16:34:46 +00:00
|
|
|
|
2022-02-03 13:20:48 +00:00
|
|
|
void LOCK_COFFIN();
|
|
|
|
|
2022-02-02 16:34:46 +00:00
|
|
|
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 HashMap<>());
|
|
|
|
}
|
|
|
|
|
2022-02-13 12:24:02 +00:00
|
|
|
static <T extends DefaultEnumBaseʸᴰ<?> & BãßBȍőnCoffinStoreʸᴰ<?>> void lockCoffin(T store) {
|
|
|
|
lockCoffin(store, v -> System.out.println(v));
|
|
|
|
}
|
|
|
|
|
|
|
|
static <T extends DefaultEnumBaseʸᴰ<?> & BãßBȍőnCoffinStoreʸᴰ<?>> void lockCoffin(T store, Consumer<String> logHandler) {
|
|
|
|
logHandler.accept("Lock: "+store.BãßClassNaam()+" since: "+store.BãßAuthorCopyright());
|
|
|
|
for (Object o:store.BãßInstances()) {
|
|
|
|
BãßBȍőnCoffinStoreʸᴰ<?> coffin = BãßBȍőnCoffinStoreʸᴰ.class.cast(o);
|
|
|
|
BãßBȍőnCoffinOpenʸᴰ<?> coffinOpen = BãßBȍőnCoffinOpenʸᴰ.class.cast(coffin.GET_BBC());
|
|
|
|
coffinOpen.LOCK_COFFIN();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-02 17:06:12 +00:00
|
|
|
static <Y extends BãßBȍőnCoffinStoreKeyʸᴰ> BãßBȍőnCoffinOpenʸᴰ<Y> newInstance() {
|
|
|
|
return new BãßBȍőnCoffinOpenʸᴰ<Y>() {
|
2022-02-02 16:34:46 +00:00
|
|
|
final Map<Y,Object> initMap = new HashMap<>();
|
2022-02-03 13:20:48 +00:00
|
|
|
volatile boolean deathLock = false;
|
2022-02-02 16:34:46 +00:00
|
|
|
|
2022-02-03 13:20:48 +00:00
|
|
|
@Override
|
|
|
|
public void LOCK_COFFIN() {
|
|
|
|
deathLock = true;
|
|
|
|
}
|
|
|
|
|
2022-02-02 16:34:46 +00:00
|
|
|
@Override
|
|
|
|
public Object GET_OBJ(Y key) {
|
|
|
|
return initMap.get(key);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Object PUT_OBJ(Y key, Object value) {
|
2022-02-03 13:20:48 +00:00
|
|
|
if (deathLock) {
|
|
|
|
throw new IllegalStateException("Can't cheat death in closed coffin.");
|
|
|
|
}
|
2022-02-02 16:34:46 +00:00
|
|
|
return initMap.put(key, value);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|