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

net.jbock.convert.MappingFinder Maven / Gradle / Ivy

There is a newer version: 5.18
Show newest version
package net.jbock.convert;

import dagger.Lazy;
import io.jbock.util.Either;
import net.jbock.annotated.AnnotatedMethod;
import net.jbock.common.ValidationFailure;
import net.jbock.convert.matching.AutoValidator;
import net.jbock.convert.matching.ConverterValidator;
import net.jbock.validate.ValidateScope;

import javax.inject.Inject;

@ValidateScope
public class MappingFinder {

    private final Lazy autoConverterFinder;
    private final Lazy converterValidator;

    @Inject
    MappingFinder(
            Lazy autoConverterFinder,
            Lazy converterValidator) {
        this.autoConverterFinder = autoConverterFinder;
        this.converterValidator = converterValidator;
    }

    public 
    Either> findMapping(
            M sourceMethod) {
        return sourceMethod.converter()
                .map(converter -> converterValidator.get().findMapping(sourceMethod, converter))
                .orElseGet(() -> autoConverterFinder.get().findMapping(sourceMethod));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy