All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jtwig.reflection.MethodInvokerBuilder Maven / Gradle / Ivy

There is a newer version: 5.87.0.RELEASE
Show newest version
package org.jtwig.reflection;

import org.jtwig.reflection.input.InputParameterResolverContextFactory;
import org.jtwig.reflection.input.InputParameterResolverFactory;
import org.jtwig.reflection.input.InputParameterValueResolver;
import org.jtwig.reflection.resolver.BeanMethodResolverImpl;
import org.jtwig.reflection.resolver.argument.ArgumentResolver;
import org.jtwig.reflection.resolver.argument.CompositeArgumentResolver;
import org.jtwig.reflection.resolver.argument.InputArgumentResolverFactory;
import org.jtwig.reflection.resolver.argument.ParameterResolver;

import java.util.ArrayList;
import java.util.Collection;

public class MethodInvokerBuilder {
    private final Collection argumentResolvers = new ArrayList();
    private InputParameterValueResolver inputParameterValueResolver;
    private InputParameterResolverFactory inputParameterResolverFactory;

    public MethodInvokerBuilder withInputParameterValueResolver(InputParameterValueResolver inputParameterValueResolver) {
        this.inputParameterValueResolver = inputParameterValueResolver;
        return this;
    }


    public MethodInvokerBuilder withInputParameterResolverFactory(InputParameterResolverFactory inputParameterResolver) {
        this.inputParameterResolverFactory = inputParameterResolver;
        return this;
    }

    public MethodInvokerBuilder withArgumentResolver (ArgumentResolver resolver) {
        this.argumentResolvers.add(resolver);
        return this;
    }

    public MethodInvokerBuilder withArgumentResolvers (Collection resolvers) {
        this.argumentResolvers.addAll(resolvers);
        return this;
    }

    public MethodInvoker build () {
        return new MethodInvokerImpl(new BeanMethodResolverImpl(
                new InputArgumentResolverFactory(inputParameterValueResolver, inputParameterResolverFactory, new InputParameterResolverContextFactory()),
                new ParameterResolver(new CompositeArgumentResolver(argumentResolvers))
        ));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy