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

org.jtwig.reflection.resolver.argument.ParameterResolver Maven / Gradle / Ivy

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

import com.google.common.base.Optional;
import com.google.common.base.Supplier;
import org.jtwig.reflection.model.Value;
import org.jtwig.reflection.model.java.JavaMethodArgument;
import org.jtwig.reflection.util.Optionals;

public class ParameterResolver {
    private final ArgumentResolver argumentResolver;

    public ParameterResolver(ArgumentResolver argumentResolver) {
        this.argumentResolver = argumentResolver;
    }

    public Optional resolve (InputArgumentResolver inputArgumentResolver, JavaMethodArgument methodArgument) {
        return Optionals
                .orOptionalSupplier(
                        inputArgumentResolver.resolve(methodArgument),
                        resolveStaticArgument(methodArgument));
    }

    private Supplier> resolveStaticArgument(final JavaMethodArgument javaMethodArgument) {
        return new Supplier>() {
            @Override
            public Optional get() {
                return argumentResolver.resolve(javaMethodArgument);
            }
        };
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy