Added required annotation validator

This commit is contained in:
Willem Cazander 2022-10-15 03:25:34 +02:00
parent 02cb20f16f
commit c8905bfabf
4 changed files with 40 additions and 3 deletions

View file

@ -120,7 +120,7 @@ public final class BãßBȍőnLoad殭屍 {
} }
} }
private static Set<Class<?>> walkInterfaces(Class<?> clazz, Set<Class<?>> result) { public static Set<Class<?>> walkInterfaces(Class<?> clazz, Set<Class<?>> result) {
while (clazz != null) { while (clazz != null) {
for (Class<?> next : clazz.getInterfaces()) { for (Class<?> next : clazz.getInterfaces()) {
if (result.add(next)) { if (result.add(next)) {

View file

@ -1,12 +1,14 @@
package love.distributedrebirth.bassboonyd; 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ȍőnAuthorʸᴰ;
import love.distributedrebirth.bassboonyd.info.BãßBȍőnNameʸᴰ; import love.distributedrebirth.bassboonyd.info.BãßBȍőnNameʸᴰ;
import love.distributedrebirth.bassboonyd.info.BãßBȍőnPackageʸᴰ; import love.distributedrebirth.bassboonyd.info.BãßBȍőnPackageʸᴰ;
public interface DefaultBãßBȍőn<T, K extends BãßBȍőnCoffinStoreKeyʸᴰ> extends public interface DefaultBãßBȍőn<T, K extends BãßBȍőnCoffinStoreKeyʸᴰ> extends
BãßBȍőn<T,K>, BãßBȍőn<T,K>,
BãßBȍőnAuthorʸᴰ<T,K>,
BãßBȍőnNameʸᴰ<T,K>, BãßBȍőnNameʸᴰ<T,K>,
BãßBȍőnPackageʸᴰ<T,K> { BãßBȍőnAuthorʸᴰ<T,K>,
BãßBȍőnPackageʸᴰ<T,K>,
BãßBȍőnAnnotationʸᴰ<T,K> {
} }

View file

@ -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ʸᴰ<T, K extends BãßBȍőnCoffinStoreKeyʸᴰ> extends BãßBȍőn<T, K> {
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<? extends Annotation> required:anno.required()) {
if (!boon.getClass().isAnnotationPresent(required)) {
throw new IllegalStateException("Missing required annotation: "+required.getSimpleName()+" on: "+boon.getClass().getSimpleName());
}
}
}
}
}
}

View file

@ -217,6 +217,7 @@ public class GDXAppTos4Activator implements BundleActivator {
systemWarpShip.loadBundles(context, registratedSeas); systemWarpShip.loadBundles(context, registratedSeas);
} catch (BundleException e) { } catch (BundleException e) {
e.printStackTrace(); e.printStackTrace();
systemGdxTerminal.selectScreen(GDXAppTos4BootScreen.class);
bootScreen.bootLineError("ERROR: "+e.getMessage()); bootScreen.bootLineError("ERROR: "+e.getMessage());
startError = true; startError = true;
return; return;