- add prototype Interactioncheck impementation.
All checks were successful
github-mirror / push-github (push) Successful in 4s
Build / Gradle-Build (push) Successful in 12s
Test / Gradle-Test (push) Successful in 16s

- refactor dependency injection to have all widely used dependencies in the Marinara class.
This commit is contained in:
2024-11-28 10:32:48 +01:00
parent 582e0f0bae
commit f89ae5e425
9 changed files with 183 additions and 42 deletions

View File

@@ -0,0 +1,32 @@
package net.tomatentum.marinara.registry;
import java.lang.annotation.Annotation;
import java.lang.reflect.TypeVariable;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import net.tomatentum.marinara.checks.InteractionCheck;
public class InteractionCheckRegistry {
private List<InteractionCheck<?>> checks;
public InteractionCheckRegistry() {
this.checks = new ArrayList<>();
}
public void addCheck(InteractionCheck<?> check) {
checks.add(check);
}
public Optional<InteractionCheck<?>> getCheckFromAnnotation(Class<? extends Annotation> annotation) {
for (InteractionCheck<?> interactionCheck : checks) {
TypeVariable<?> type = interactionCheck.getClass().getTypeParameters()[0];
if (type.getClass().equals(annotation.getClass()))
return Optional.of(interactionCheck);
}
return Optional.empty();
}
}