fix #123 allow to specify extra annotations on repositories/methods
[yosql.git] / yosql-models / yosql-models-configuration / src / main / java / wtf / metio / yosql / models / configuration / ResultRowConverter.java
blobcf6aed849ac26a9b77d973ab0ae38da311ab021d
1 /*
2 * This file is part of yosql. It is subject to the license terms in the LICENSE file found in the top-level
3 * directory of this distribution and at https://creativecommons.org/publicdomain/zero/1.0/. No part of yosql,
4 * including this file, may be copied, modified, propagated, or distributed except according to the terms contained
5 * in the LICENSE file.
6 */
7 package wtf.metio.yosql.models.configuration;
9 import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
10 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
11 import com.squareup.javapoet.TypeName;
12 import de.xn__ho_hia.javapoet.TypeGuesser;
13 import org.immutables.value.Value;
15 import java.util.Optional;
17 @Value.Immutable
18 @JsonSerialize(
19 as = ImmutableResultRowConverter.class
21 @JsonDeserialize(
22 as = ImmutableResultRowConverter.class
24 public interface ResultRowConverter {
26 //region builders
28 static ImmutableResultRowConverter.Builder builder() {
29 return ImmutableResultRowConverter.builder();
32 //endregion
34 /**
35 * @return The (short) alias of this converter.
37 Optional<String> alias();
39 /**
40 * @return The fully-qualified type name of this converter.
42 Optional<String> converterType();
44 /**
45 * @return The name of the method to use while converting values.
47 Optional<String> methodName();
49 /**
50 * @return The fully-qualified result type of this converter.
52 Optional<String> resultType();
54 //region derived
56 @Value.Lazy
57 default Optional<TypeName> resultTypeName() {
58 return resultType().map(TypeGuesser::guessTypeName);
61 @Value.Lazy
62 default Optional<TypeName> converterTypeName() {
63 return converterType().map(TypeGuesser::guessTypeName);
66 //endregion