feat(core): add Context generic
Build / Gradle-Build (push) Successful in 15s
Publish / Gradle-Publish (push) Successful in 13s
Test / Gradle-Test (push) Successful in 13s

This commit is contained in:
tueem committed 2025-04-11 20:44:03 +02:00
1 parent c44b874b41
commit 2a6eba871d
13 files changed
+77 -77

No files matched your search

@@ -11,24 +11,24 @@ import java.util.Set;
import net.tomatentum.cutin.ReflectedMethodFactory;
import net.tomatentum.cutin.method.ReflectedMethod;
public class LoneMethodContainer<I extends Object> implements MethodContainer<I> {
public class LoneMethodContainer<I extends Object, C extends Object> implements MethodContainer<I, C> {
private Map<I, ReflectedMethod<I>> methodStore;
private ReflectedMethodFactory<I> factory;
private Map<I, ReflectedMethod<I, C>> methodStore;
private ReflectedMethodFactory<I, C> factory;
public LoneMethodContainer(ReflectedMethodFactory<I> factory) {
public LoneMethodContainer(ReflectedMethodFactory<I, C> factory) {
this.methodStore = new HashMap<>();
this.factory = factory;
}
@Override
public MethodContainer<I> addMethod(ReflectedMethod<I> method) {
public MethodContainer<I, C> addMethod(ReflectedMethod<I, C> method) {
this.methodStore.put(method.identifier(), method);
return this;
}
@Override
public MethodContainer<I> addMethods(Object containingObject, Method... methods) {
public MethodContainer<I, C> addMethods(Object containingObject, Method... methods) {
for (Method method : methods)
this.factory.produce(method, containingObject)
.ifPresent(this::addMethod);
@@ -41,17 +41,17 @@ public class LoneMethodContainer<I extends Object> implements MethodContainer<I>
}
@Override
public Collection<ReflectedMethod<I>> methods() {
public Collection<ReflectedMethod<I, C>> methods() {
return this.methodStore.values();
}
@Override
public Collection<ReflectedMethod<I>> findFor(I identifier) {
public Collection<ReflectedMethod<I, C>> findFor(I identifier) {
return Arrays.asList(this.methodStore.get(identifier));
}
@Override
public Optional<ReflectedMethod<I>> findFirstFor(I identifier) {
public Optional<ReflectedMethod<I, C>> findFirstFor(I identifier) {
return findFor(identifier).stream().findFirst();
}