net.jbock.convert.MappingFinder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jbock-compiler Show documentation
Show all versions of jbock-compiler Show documentation
jbock annotation processor
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));
}
}