2022-02-02 16:34:46 +00:00
|
|
|
package love.distributedrebirth.bassboonyd;
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.Map;
|
|
|
|
|
2022-02-02 17:01:10 +00:00
|
|
|
@BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天")
|
2022-02-02 17:06:12 +00:00
|
|
|
public interface BãßBȍőnCoffinOpenʸᴰ<T extends BãßBȍőnCoffinStoreKeyʸᴰ> extends BãßBȍőnCoffinʸᴰ<T> {
|
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-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);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|