feat(factory): introduce Mutable and Immutable methodfactory and change parser pipeline
This commit is contained in:
parent
ad2c4c00f6
commit
a2bdb549f9
@ -0,0 +1,20 @@
|
|||||||
|
package net.tomatentum.cutin.factory;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import net.tomatentum.cutin.MethodParser;
|
||||||
|
|
||||||
|
public abstract class ImmutableMethodFactory<I extends Object, C extends Object> implements ReflectedMethodFactory.Factory<I, C> {
|
||||||
|
|
||||||
|
protected Set<MethodParser> parser;
|
||||||
|
|
||||||
|
protected ImmutableMethodFactory(MethodParser... parser) {
|
||||||
|
this.parser = Set.of(parser);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<MethodParser> parser() {
|
||||||
|
return this.parser;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package net.tomatentum.cutin.factory;
|
||||||
|
|
||||||
|
import net.tomatentum.cutin.MethodParser;
|
||||||
|
|
||||||
|
public abstract class MutableMethodFactory<I extends Object, C extends Object> extends ImmutableMethodFactory<I, C> {
|
||||||
|
|
||||||
|
public MutableMethodFactory<I, C> addParser(MethodParser parser) {
|
||||||
|
super.parser.add(parser);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MutableMethodFactory<I, C> removeParser(MethodParser parser) {
|
||||||
|
super.parser.remove(parser);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -17,7 +17,7 @@ public interface ReflectedMethodFactory<I extends Object, C extends Object> {
|
|||||||
public interface Factory<I extends Object, C extends Object> {
|
public interface Factory<I extends Object, C extends Object> {
|
||||||
|
|
||||||
Optional<ReflectedMethod<I, C>> produce(Method method, Object containingObject, ParserResults parserResults);
|
Optional<ReflectedMethod<I, C>> produce(Method method, Object containingObject, ParserResults parserResults);
|
||||||
void addParser(Set<MethodParser> parser);
|
Set<MethodParser> parser();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,8 +55,7 @@ public class ReflectedMethodFactoryImpl<I extends Object, C extends Object> impl
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Optional<ReflectedMethod<I, C>> factoryProduce(Factory<I, C> factory, Method method, Object containingClass) {
|
private Optional<ReflectedMethod<I, C>> factoryProduce(Factory<I, C> factory, Method method, Object containingClass) {
|
||||||
Set<MethodParser> parser = new HashSet<>();
|
Set<MethodParser> parser = factory.parser();
|
||||||
factory.addParser(parser);
|
|
||||||
ParserResults results = ParserResults.create(parser, method, containingClass);
|
ParserResults results = ParserResults.create(parser, method, containingClass);
|
||||||
return factory.produce(method, containingClass, results);
|
return factory.produce(method, containingClass, results);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user