put a mononoke spider princess per bean grave
This commit is contained in:
parent
84f3a34f21
commit
37ab7ae4be
23 changed files with 83 additions and 71 deletions
|
|
@ -12,37 +12,63 @@ import love.distributedrebirth.bassboonyd.coffin.BãßBȍőnCoffin;
|
|||
import love.distributedrebirth.bassboonyd.coffin.BãßBȍőnCoffinNail;
|
||||
import love.distributedrebirth.bassboonyd.coffin.BãßBȍőnCoffinOpen;
|
||||
import love.distributedrebirth.bassboonyd.sinit.BãßBȍőnꝐŕḯṿª₮ḕ;
|
||||
import love.distributedrebirth.bassboonyd.spider.BãßBȍőnSpider;
|
||||
|
||||
@BãßBȍőnAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天")
|
||||
public interface Bãß {
|
||||
|
||||
public static final class Ꝑŕḯṿª₮ḕ implements BãßBȍőnꝐŕḯṿª₮ḕ {
|
||||
private static final Map<Object, BãßBȍőnCoffin<?>> GRAVE_YARD = new WeakHashMap<>(); // TODO: test bean gc
|
||||
private static final Map<Object, BȍőnGrave> GRAVE_YARD = new WeakHashMap<>();
|
||||
private static final ReadWriteLock FUNERAL = new ReentrantReadWriteLock();
|
||||
|
||||
private Ꝑŕḯṿª₮ḕ() {
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
public static final <T, K extends BãßBȍőnCoffinNail> void 仙ᴵᴺᴵᵀ(BãßBȍőnʸᴰ<T,K> boon, Consumer<BãßBȍőnCoffinOpen<K>>...coffinFillers) {
|
||||
BãßBȍőnPhaseLoader.CAST_BONE_MAGIC(boon, coffinFillers);
|
||||
public static final <T, K extends BãßBȍőnCoffinNail> void 魎ᴵᴺᴵᵀ(BãßBȍőnʸᴰ<T,K> boon, Consumer<BãßBȍőnCoffinOpen<K>>...coffinFillers) { // mononoke-init
|
||||
BãßBȍőnPhaseLoader.CAST_BONE_MAGIC(boon, 墳ᴼᶠ(boon).spider, coffinFillers);
|
||||
}
|
||||
|
||||
public static final <T, K extends BãßBȍőnCoffinNail> void 鎖ᴳᴿᴬⱽᴱ(BãßBȍőnʸᴰ<T,K> boon) {
|
||||
BãßBȍőnCoffin<K> coffin = (BãßBȍőnCoffin<K>)boon.toBBC();
|
||||
protected static final <T, K extends BãßBȍőnCoffinNail> BãßBȍőnCoffin<K> 殭屍ᴼᶠ(BãßBȍőnʸᴰ<T,K> boon) { // zombie-of
|
||||
return 墳ᴼᶠ(boon).石棺ᴹᵃᵍᶦᶜ(boon.getClass());
|
||||
}
|
||||
|
||||
public static final <T, K extends BãßBȍőnCoffinNail> void 鎖ᴳᴿᴬⱽᴱ(BãßBȍőnʸᴰ<T,K> boon) { // lock-grave
|
||||
BãßBȍőnCoffin<K> coffin = boon.toBBC();
|
||||
if (!(coffin instanceof BãßBȍőnCoffinOpen)) {
|
||||
return; // already closed
|
||||
}
|
||||
Lock graveDigger = FUNERAL.writeLock();
|
||||
Lock graveDigger = FUNERAL.readLock();
|
||||
graveDigger.lock();
|
||||
try {
|
||||
GRAVE_YARD.remove(boon.toBBCHeadStoneʸᴰ());
|
||||
GRAVE_YARD.put(boon.toBBCHeadStoneʸᴰ(), ((BãßBȍőnCoffinOpen<K>)coffin).LOCK_COFFIN());
|
||||
GRAVE_YARD.get(boon).棺ᴸᵒᶜᵏ();
|
||||
} finally {
|
||||
graveDigger.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static final BȍőnGrave 墳ᴼᶠ(BãßBȍőnʸᴰ<?,?> boon) { // grave-of
|
||||
BȍőnGrave boonGrave = null;
|
||||
Lock bibleReader = FUNERAL.readLock(); // Can't force enum only, thus no jvm safety
|
||||
bibleReader.lock();
|
||||
try {
|
||||
boonGrave = GRAVE_YARD.get(boon);
|
||||
} finally {
|
||||
bibleReader.unlock();
|
||||
}
|
||||
if (boonGrave == null) {
|
||||
Lock shemiraWriter = FUNERAL.writeLock();
|
||||
shemiraWriter.lock();
|
||||
try {
|
||||
boonGrave = new BȍőnGrave();
|
||||
GRAVE_YARD.put(boon, boonGrave);
|
||||
} finally {
|
||||
shemiraWriter.unlock();
|
||||
}
|
||||
}
|
||||
return boonGrave;
|
||||
}
|
||||
|
||||
//TODO
|
||||
// public static <T> T 豆ᴺᴱᵂ(Class<T> seedling) {
|
||||
// try {
|
||||
|
|
@ -54,28 +80,24 @@ public interface Bãß {
|
|||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
public static final class BȍőnGrave {
|
||||
private final BãßBȍőnSpider spider;
|
||||
private BãßBȍőnCoffin<?> coffin;
|
||||
|
||||
private BȍőnGrave() {
|
||||
this.spider = new BãßBȍőnSpider();
|
||||
this.coffin = BãßBȍőnCoffinOpen.newInstance();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected static final <T, K extends BãßBȍőnCoffinNail> BãßBȍőnCoffin<K> 殭屍ᴼᶠ(BãßBȍőnʸᴰ<T,K> boon) {
|
||||
BãßBȍőnCoffin<K> zombieCoffin = null;
|
||||
Lock bibleReader = Bãß.Ꝑŕḯṿª₮ḕ.FUNERAL.readLock(); // Can't force enum only, thus no jvm safety
|
||||
bibleReader.lock();
|
||||
try {
|
||||
zombieCoffin = (BãßBȍőnCoffin<K>) Bãß.Ꝑŕḯṿª₮ḕ.GRAVE_YARD.get(boon.toBBCHeadStoneʸᴰ());
|
||||
} finally {
|
||||
bibleReader.unlock();
|
||||
}
|
||||
if (zombieCoffin == null) {
|
||||
Lock shemiraWriter = Bãß.Ꝑŕḯṿª₮ḕ.FUNERAL.writeLock();
|
||||
shemiraWriter.lock();
|
||||
try {
|
||||
zombieCoffin = BãßBȍőnCoffinOpen.newInstance();
|
||||
Bãß.Ꝑŕḯṿª₮ḕ.GRAVE_YARD.put(boon.toBBCHeadStoneʸᴰ(), zombieCoffin);
|
||||
} finally {
|
||||
shemiraWriter.unlock();
|
||||
}
|
||||
}
|
||||
return zombieCoffin;
|
||||
private <T, K extends BãßBȍőnCoffinNail> BãßBȍőnCoffin<K> 石棺ᴹᵃᵍᶦᶜ(Class<T> coffinType) { // sarcophagus-magic
|
||||
return (BãßBȍőnCoffin<K>) coffin;
|
||||
}
|
||||
|
||||
private void 棺ᴸᵒᶜᵏ() { // coffin-lock
|
||||
coffin = BãßBȍőnCoffinOpen.FROM(coffin).LOCK_COFFIN();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,35 +24,32 @@ import love.distributedrebirth.bassboonyd.spider.BãßBȍőnSpiderWire注;
|
|||
@BãßBȍőnAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天")
|
||||
public final class BãßBȍőnPhaseLoader {
|
||||
|
||||
private static final BãßBȍőnSpider BLACK_WIDOW = new BãßBȍőnSpider();
|
||||
private static final Set<Class<?>> SCANNED = new LinkedHashSet<>();
|
||||
|
||||
private BãßBȍőnPhaseLoader() {
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
protected static <T, K extends BãßBȍőnCoffinNail> void CAST_BONE_MAGIC(BãßBȍőnʸᴰ<T,K> boon, Consumer<BãßBȍőnCoffinOpen<K>>...coffinFillers) {
|
||||
protected static <T, K extends BãßBȍőnCoffinNail> void CAST_BONE_MAGIC(BãßBȍőnʸᴰ<T,K> boon, BãßBȍőnSpider spider, Consumer<BãßBȍőnCoffinOpen<K>>...coffinFillers) {
|
||||
BãßBȍőnCoffinOpen<K> bbc = BãßBȍőnCoffinOpen.FROM(boon);
|
||||
try {
|
||||
for (Consumer<BãßBȍőnCoffinOpen<K>> embalmFactory:coffinFillers) {
|
||||
embalmFactory.accept(bbc);
|
||||
}
|
||||
initPrivate(boon);
|
||||
initSpiderEggs(boon);
|
||||
initSpiderWires(boon);
|
||||
initSpiderEggs(boon, spider);
|
||||
initSpiderWires(boon, spider);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static void initSpiderWires(Object boon) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||
private static void initSpiderWires(Object boon, BãßBȍőnSpider spider) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||
//System.out.println("SCAN-BOON-FIELD: "+boon.getClass().getSimpleName());
|
||||
for (Field m:boon.getClass().getDeclaredFields()) {
|
||||
if (!m.isAnnotationPresent(BãßBȍőnSpiderWire注.class)) {
|
||||
continue;
|
||||
}
|
||||
BãßBȍőnSpiderWire注 anno = m.getAnnotation(BãßBȍőnSpiderWire注.class);
|
||||
BãßBȍőnSpiderSilk silkRoad = BLACK_WIDOW.silkRoad(m.getType());
|
||||
BãßBȍőnSpiderSilk silkRoad = spider.silkRoad(m.getType());
|
||||
Object bean = silkRoad.senseWire(boon, anno.name(), anno.description());
|
||||
//System.out.println("type: "+ m.getType() +" wth name: "+anno.name()+" of boon: "+boon.getClass());
|
||||
|
||||
|
|
@ -61,25 +58,21 @@ public final class BãßBȍőnPhaseLoader {
|
|||
}
|
||||
}
|
||||
|
||||
private static <T, K extends BãßBȍőnCoffinNail> void initSpiderEggs(BãßBȍőnʸᴰ<T,K> boon) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||
private static <T, K extends BãßBȍőnCoffinNail> void initSpiderEggs(BãßBȍőnʸᴰ<T,K> boon, BãßBȍőnSpider spider) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||
for (Class<?> interfaceClass:walkInterfaces(boon.getClass(), new LinkedHashSet<>())) {
|
||||
for (Class<?> declaredClass:((Class<?>) interfaceClass).getDeclaredClasses()) {
|
||||
initSpiderEggRegistrate(boon, declaredClass);
|
||||
initSpiderEggRegistrate(boon, spider, declaredClass);
|
||||
}
|
||||
}
|
||||
for (Class<?> declaredClass:boon.getClass().getDeclaredClasses()) {
|
||||
initSpiderEggRegistrate(boon, declaredClass);
|
||||
initSpiderEggRegistrate(boon, spider, declaredClass);
|
||||
}
|
||||
}
|
||||
|
||||
private static <T, K extends BãßBȍőnCoffinNail> void initSpiderEggRegistrate(BãßBȍőnʸᴰ<T,K> boon, Class<?> declaredClass) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||
private static <T, K extends BãßBȍőnCoffinNail> void initSpiderEggRegistrate(BãßBȍőnʸᴰ<T,K> boon, BãßBȍőnSpider spider, Class<?> declaredClass) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||
if (!BãßBȍőnꝐŕḯṿª₮ḕ.class.isAssignableFrom(declaredClass)) {
|
||||
return;
|
||||
}
|
||||
if (SCANNED.contains(declaredClass)) {
|
||||
return;
|
||||
}
|
||||
SCANNED.add(declaredClass);
|
||||
for (Method m:declaredClass.getDeclaredMethods()) {
|
||||
if (!m.isAnnotationPresent(BãßBȍőnSpiderEgg注.class)) {
|
||||
continue;
|
||||
|
|
@ -87,7 +80,7 @@ public final class BãßBȍőnPhaseLoader {
|
|||
//System.out.println("annoEgg: "+boon.getClass().getSimpleName()+"."+boon+" from: "+declaredClass.getName()+" m="+m.toGenericString());
|
||||
|
||||
m.setAccessible(true);
|
||||
BLACK_WIDOW.registrateEgg(m.getReturnType(), m);
|
||||
spider.registrateEgg(m.getReturnType(), m);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,11 +7,6 @@ import love.distributedrebirth.bassboonyd.coffin.BãßBȍőnCoffinNail;
|
|||
@BãßBȍőnAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天")
|
||||
public interface BãßBȍőnʸᴰ<T, K extends BãßBȍőnCoffinNail> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
default T toBBCHeadStoneʸᴰ() {
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
default BãßBȍőnCoffin<K> toBBC() {
|
||||
return Bãß.Ꝑŕḯṿª₮ḕ.殭屍ᴼᶠ(this);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue