From c8905bfabf76f2177c057495fc875f048ee9adc0 Mon Sep 17 00:00:00 2001 From: Willem Date: Sat, 15 Oct 2022 03:25:34 +0200 Subject: [PATCH] Added required annotation validator --- .../bassboonyd/BãßBȍőnLoad殭屍.java | 2 +- .../bassboonyd/DefaultBãßBȍőn.java | 6 ++-- .../bassboonyd/info/BãßBȍőnAnnotationʸᴰ.java | 34 +++++++++++++++++++ .../gdxapp4d/tos4/GDXAppTos4Activator.java | 1 + 4 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboonyd/info/BãßBȍőnAnnotationʸᴰ.java diff --git a/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboonyd/BãßBȍőnLoad殭屍.java b/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboonyd/BãßBȍőnLoad殭屍.java index e750c715..681b4b61 100644 --- a/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboonyd/BãßBȍőnLoad殭屍.java +++ b/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboonyd/BãßBȍőnLoad殭屍.java @@ -120,7 +120,7 @@ public final class BãßBȍőnLoad殭屍 { } } - private static Set> walkInterfaces(Class clazz, Set> result) { + public static Set> walkInterfaces(Class clazz, Set> result) { while (clazz != null) { for (Class next : clazz.getInterfaces()) { if (result.add(next)) { diff --git a/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboonyd/DefaultBãßBȍőn.java b/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboonyd/DefaultBãßBȍőn.java index 07304bd6..af6c6df0 100644 --- a/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboonyd/DefaultBãßBȍőn.java +++ b/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboonyd/DefaultBãßBȍőn.java @@ -1,12 +1,14 @@ package love.distributedrebirth.bassboonyd; +import love.distributedrebirth.bassboonyd.info.BãßBȍőnAnnotationʸᴰ; import love.distributedrebirth.bassboonyd.info.BãßBȍőnAuthorʸᴰ; import love.distributedrebirth.bassboonyd.info.BãßBȍőnNameʸᴰ; import love.distributedrebirth.bassboonyd.info.BãßBȍőnPackageʸᴰ; public interface DefaultBãßBȍőn extends BãßBȍőn, - BãßBȍőnAuthorʸᴰ, BãßBȍőnNameʸᴰ, - BãßBȍőnPackageʸᴰ { + BãßBȍőnAuthorʸᴰ, + BãßBȍőnPackageʸᴰ, + BãßBȍőnAnnotationʸᴰ { } diff --git a/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboonyd/info/BãßBȍőnAnnotationʸᴰ.java b/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboonyd/info/BãßBȍőnAnnotationʸᴰ.java new file mode 100644 index 00000000..30262454 --- /dev/null +++ b/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboonyd/info/BãßBȍőnAnnotationʸᴰ.java @@ -0,0 +1,34 @@ +package love.distributedrebirth.bassboonyd.info; + +import java.lang.annotation.Annotation; +import java.util.LinkedHashSet; + +import love.distributedrebirth.bassboonyd.BãßBȍőn; +import love.distributedrebirth.bassboonyd.BãßBȍőnCoffinStoreKeyʸᴰ; +import love.distributedrebirth.bassboonyd.BãßBȍőnLoad殭屍; +import love.distributedrebirth.bassboonyd.BãßBȍőnꝐŕḯṿª₮ḕ; +import love.distributedrebirth.bassboonyd.BãßBȍőnꝐŕḯṿª₮ḕInitPhaseʸᴰ; +import love.distributedrebirth.bassboonyd.BãßBȍőnꝐŕḯṿª₮ḕInit注; + +@BãßBȍőnAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天") +@BãßBȍőnAnnotation注(optional = {BãßBȍőnPackage注.class}) +public interface BãßBȍőnAnnotationʸᴰ extends BãßBȍőn { + + public static class Ꝑŕḯṿª₮ḕ implements BãßBȍőnꝐŕḯṿª₮ḕ { + + @BãßBȍőnꝐŕḯṿª₮ḕInit注(phase = BãßBȍőnꝐŕḯṿª₮ḕInitPhaseʸᴰ.BOON_PRE_BOOT) + private static void init(BãßBȍőn boon) { + for (Class interfaceClass:BãßBȍőnLoad殭屍.walkInterfaces(boon.getClass(), new LinkedHashSet<>())) { + BãßBȍőnAnnotation注 anno = interfaceClass.getAnnotation(BãßBȍőnAnnotation注.class); + if (anno == null) { + continue; + } + for (Class required:anno.required()) { + if (!boon.getClass().isAnnotationPresent(required)) { + throw new IllegalStateException("Missing required annotation: "+required.getSimpleName()+" on: "+boon.getClass().getSimpleName()); + } + } + } + } + } +} diff --git a/gdxapp4d-tos4/src/main/java/love/distributedrebirth/gdxapp4d/tos4/GDXAppTos4Activator.java b/gdxapp4d-tos4/src/main/java/love/distributedrebirth/gdxapp4d/tos4/GDXAppTos4Activator.java index d4db1353..85336a06 100644 --- a/gdxapp4d-tos4/src/main/java/love/distributedrebirth/gdxapp4d/tos4/GDXAppTos4Activator.java +++ b/gdxapp4d-tos4/src/main/java/love/distributedrebirth/gdxapp4d/tos4/GDXAppTos4Activator.java @@ -217,6 +217,7 @@ public class GDXAppTos4Activator implements BundleActivator { systemWarpShip.loadBundles(context, registratedSeas); } catch (BundleException e) { e.printStackTrace(); + systemGdxTerminal.selectScreen(GDXAppTos4BootScreen.class); bootScreen.bootLineError("ERROR: "+e.getMessage()); startError = true; return;