From 1919f2bd41409ef84f19d9d5fd8691e3edc54b15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Ho=C3=9F?= Date: Fri, 2 Oct 2020 19:12:28 +0200 Subject: [PATCH] fix #107 --- yosql-core/pom.xml | 15 +--- .../dagger/DefaultConfigurationModule.java | 14 +-- .../AnnotationConfiguration.java | 45 ++++------ .../configuration/FileConfiguration.java | 45 +++++----- .../configuration/JavaConfiguration.java | 28 ++---- .../JdbcFieldsConfiguration.java | 22 ++--- .../configuration/JdbcNamesConfiguration.java | 64 ++++---------- .../configuration/LoggingConfiguration.java | 26 +++--- .../configuration/MethodConfiguration.java | 88 +++++-------------- .../configuration/NameConfiguration.java | 28 ++---- .../RepositoryConfiguration.java | 24 ++--- .../configuration/ResourceConfiguration.java | 20 ++--- .../configuration/ResultConfiguration.java | 24 ++--- .../configuration/RuntimeConfiguration.java | 68 ++++---------- .../configuration/RxJavaConfiguration.java | 23 ++--- .../configuration/StatementConfiguration.java | 21 ++--- .../configuration/VariableConfiguration.java | 24 ++--- .../wtf/metio/yosql/model/package-info.java | 9 ++ .../ModelConfigurationObjectMother.java | 8 +- .../java/wtf/metio/yosql/maven/Methods.java | 6 +- .../java/wtf/metio/yosql/maven/Variables.java | 2 +- 21 files changed, 209 insertions(+), 395 deletions(-) diff --git a/yosql-core/pom.xml b/yosql-core/pom.xml index 1f8e432db..bc7a31c57 100644 --- a/yosql-core/pom.xml +++ b/yosql-core/pom.xml @@ -95,17 +95,10 @@ - com.google.auto.value - auto-value - - - com.google.auto.value - auto-value-annotations - - - org.inferred - freebuilder - 2.6.1 + org.immutables + value + 2.8.8 + provided diff --git a/yosql-core/src/main/java/wtf/metio/yosql/dagger/DefaultConfigurationModule.java b/yosql-core/src/main/java/wtf/metio/yosql/dagger/DefaultConfigurationModule.java index e32ab737c..0725a85b0 100644 --- a/yosql-core/src/main/java/wtf/metio/yosql/dagger/DefaultConfigurationModule.java +++ b/yosql-core/src/main/java/wtf/metio/yosql/dagger/DefaultConfigurationModule.java @@ -63,7 +63,7 @@ VariableConfiguration provideVariableOptions(final JavaConfiguration javaConfigu ? VariableTypeOptions.VAR : VariableTypeOptions.TYPE; return VariableConfiguration.builder() - .setModifiers(List.of(Modifier.FINAL)) // TODO: externalize + .addModifiers(Modifier.FINAL) .setVariableType(variableType) .build(); } @@ -136,12 +136,12 @@ MethodConfiguration provideMethodConfiguration(final Translator translator) { .setMethodRxJavaSuffix(translator.nonLocalized(METHOD_RXJAVA_SUFFIX_DEFAULT)) .setMethodEagerName(translator.nonLocalized(METHOD_EAGER_NAME_DEFAULT)) .setMethodLazyName(translator.nonLocalized(METHOD_LAZY_NAME_DEFAULT)) - .setAllowedCallPrefixes(Arrays.asList( - translator.nonLocalized(METHOD_ALLOWED_CALL_PREFIXES_DEFAULT).split(SPLIT_LIST_ENTRIES_REGEX))) - .setAllowedReadPrefixes(Arrays.asList( - translator.nonLocalized(METHOD_ALLOWED_READ_PREFIXES_DEFAULT).split(SPLIT_LIST_ENTRIES_REGEX))) - .setAllowedWritePrefixes(Arrays.asList( - translator.nonLocalized(METHOD_ALLOWED_WRITE_PREFIXES_DEFAULT).split(SPLIT_LIST_ENTRIES_REGEX))) + .addAllowedCallPrefixes(translator.nonLocalized(METHOD_ALLOWED_CALL_PREFIXES_DEFAULT) + .split(SPLIT_LIST_ENTRIES_REGEX)) + .addAllowedReadPrefixes(translator.nonLocalized(METHOD_ALLOWED_READ_PREFIXES_DEFAULT) + .split(SPLIT_LIST_ENTRIES_REGEX)) + .addAllowedWritePrefixes(translator.nonLocalized(METHOD_ALLOWED_WRITE_PREFIXES_DEFAULT) + .split(SPLIT_LIST_ENTRIES_REGEX)) .build(); } diff --git a/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/AnnotationConfiguration.java b/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/AnnotationConfiguration.java index 323c8291d..5c8e3a3d5 100644 --- a/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/AnnotationConfiguration.java +++ b/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/AnnotationConfiguration.java @@ -7,49 +7,38 @@ package wtf.metio.yosql.model.configuration; -import com.google.auto.value.AutoValue; +import org.immutables.value.Value; import wtf.metio.yosql.model.options.AnnotationClassOptions; import wtf.metio.yosql.model.options.AnnotationMemberOptions; -@AutoValue -public abstract class AnnotationConfiguration { +@Value.Immutable +public interface AnnotationConfiguration { - public static AnnotationConfiguration.Builder builder() { - return new AutoValue_AnnotationConfiguration.Builder(); + static Builder builder() { + return new Builder(); } - public abstract AnnotationClassOptions classAnnotation(); - public abstract AnnotationClassOptions fieldAnnotation(); - public abstract AnnotationClassOptions methodAnnotation(); + AnnotationClassOptions classAnnotation(); - public abstract AnnotationMemberOptions classMembers(); - public abstract AnnotationMemberOptions fieldMembers(); - public abstract AnnotationMemberOptions methodMembers(); + AnnotationClassOptions fieldAnnotation(); - public abstract String classComment(); - public abstract String fieldComment(); - public abstract String methodComment(); - public abstract String generatorName(); + AnnotationClassOptions methodAnnotation(); - @AutoValue.Builder - public abstract static class Builder { + AnnotationMemberOptions classMembers(); - public abstract Builder setClassAnnotation(AnnotationClassOptions classAnnotation); - public abstract Builder setFieldAnnotation(AnnotationClassOptions fieldAnnotation); - public abstract Builder setMethodAnnotation(AnnotationClassOptions methodAnnotation); + AnnotationMemberOptions fieldMembers(); - public abstract Builder setClassMembers(AnnotationMemberOptions classMembers); - public abstract Builder setFieldMembers(AnnotationMemberOptions fieldMembers); - public abstract Builder setMethodMembers(AnnotationMemberOptions methodMembers); + AnnotationMemberOptions methodMembers(); - public abstract Builder setClassComment(String classComment); - public abstract Builder setFieldComment(String fieldComment); - public abstract Builder setMethodComment(String methodComment); + String classComment(); - public abstract Builder setGeneratorName(String generatorName); + String fieldComment(); - public abstract AnnotationConfiguration build(); + String methodComment(); + String generatorName(); + + class Builder extends ImmutableAnnotationConfiguration.Builder { } } diff --git a/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/FileConfiguration.java b/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/FileConfiguration.java index d1c99c506..0100f518f 100644 --- a/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/FileConfiguration.java +++ b/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/FileConfiguration.java @@ -7,48 +7,43 @@ package wtf.metio.yosql.model.configuration; -import com.google.auto.value.AutoValue; +import org.immutables.value.Value; import java.nio.file.Path; -@AutoValue -public abstract class FileConfiguration { +@Value.Immutable +public interface FileConfiguration { - public static Builder builder() { - return new AutoValue_FileConfiguration.Builder(); + static FileConfiguration.Builder builder() { + return new FileConfiguration.Builder(); } /** * @return The base directory for SQL file parsing. */ - public abstract Path inputBaseDirectory(); + Path inputBaseDirectory(); /** * @return The base directory for writing .java files. */ - public abstract Path outputBaseDirectory(); + Path outputBaseDirectory(); - public abstract String sqlStatementSeparator(); - - public abstract String sqlFilesCharset(); - - public abstract String sqlFilesSuffix(); - - @AutoValue.Builder - public abstract static class Builder { - - public abstract Builder setInputBaseDirectory(Path inputBaseDirectory); - - public abstract Builder setOutputBaseDirectory(Path outputBaseDirectory); - - public abstract Builder setSqlStatementSeparator(String value); - - public abstract Builder setSqlFilesCharset(String value); + /** + * @return The SQL statement separator to use, e.g. ";". + */ + String sqlStatementSeparator(); - public abstract Builder setSqlFilesSuffix(String value); + /** + * @return The charset to use while reading SQL files, e.g. "UTF-8". + */ + String sqlFilesCharset(); - public abstract FileConfiguration build(); + /** + * @return The file suffix to use while searching for SQL files, e.g. ".sql". + */ + String sqlFilesSuffix(); + class Builder extends ImmutableFileConfiguration.Builder { } } diff --git a/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/JavaConfiguration.java b/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/JavaConfiguration.java index 02036f6e2..2fd3a3361 100644 --- a/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/JavaConfiguration.java +++ b/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/JavaConfiguration.java @@ -7,32 +7,22 @@ package wtf.metio.yosql.model.configuration; -import com.google.auto.value.AutoValue; +import org.immutables.value.Value; -@AutoValue -public abstract class JavaConfiguration { +@Value.Immutable +public interface JavaConfiguration { - public static JavaConfiguration.Builder builder() { - return new AutoValue_JavaConfiguration.Builder(); + static JavaConfiguration.Builder builder() { + return new JavaConfiguration.Builder(); } - public abstract int targetVersion(); + int targetVersion(); - public abstract boolean useVar(); + boolean useVar(); - public abstract boolean useRecords(); - - @AutoValue.Builder - public abstract static class Builder { - - public abstract Builder setTargetVersion(int targetVersion); - - public abstract Builder setUseVar(boolean useVar); - - public abstract Builder setUseRecords(boolean useVar); - - public abstract JavaConfiguration build(); + boolean useRecords(); + class Builder extends ImmutableJavaConfiguration.Builder { } } diff --git a/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/JdbcFieldsConfiguration.java b/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/JdbcFieldsConfiguration.java index 535752d47..46ff73f31 100644 --- a/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/JdbcFieldsConfiguration.java +++ b/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/JdbcFieldsConfiguration.java @@ -7,26 +7,20 @@ package wtf.metio.yosql.model.configuration; -import com.google.auto.value.AutoValue; +import org.immutables.value.Value; -@AutoValue -public abstract class JdbcFieldsConfiguration { +@Value.Immutable +public interface JdbcFieldsConfiguration { - public static Builder builder() { - return new AutoValue_JdbcFieldsConfiguration.Builder(); + static JdbcFieldsConfiguration.Builder builder() { + return new JdbcFieldsConfiguration.Builder(); } - public abstract String rawSuffix(); - public abstract String indexSuffix(); + String rawSuffix(); - @AutoValue.Builder - public abstract static class Builder { - - public abstract Builder setRawSuffix(String value); - public abstract Builder setIndexSuffix(String value); - - public abstract JdbcFieldsConfiguration build(); + String indexSuffix(); + class Builder extends ImmutableJdbcFieldsConfiguration.Builder { } } diff --git a/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/JdbcNamesConfiguration.java b/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/JdbcNamesConfiguration.java index b83e1ed9b..943dc77f0 100644 --- a/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/JdbcNamesConfiguration.java +++ b/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/JdbcNamesConfiguration.java @@ -7,68 +7,40 @@ package wtf.metio.yosql.model.configuration; -import com.google.auto.value.AutoValue; +import org.immutables.value.Value; -@AutoValue -public abstract class JdbcNamesConfiguration { +@Value.Immutable +public interface JdbcNamesConfiguration { - public static Builder builder() { - return new AutoValue_JdbcNamesConfiguration.Builder(); + static JdbcNamesConfiguration.Builder builder() { + return new JdbcNamesConfiguration.Builder(); } - public abstract String dataSource(); + String dataSource(); - public abstract String connection(); + String connection(); - public abstract String columnCount(); + String columnCount(); - public abstract String columnLabel(); + String columnLabel(); - public abstract String statement(); + String statement(); - public abstract String metaData(); + String metaData(); - public abstract String resultSet(); + String resultSet(); - public abstract String batch(); + String batch(); - public abstract String list(); + String list(); - public abstract String jdbcIndex(); + String jdbcIndex(); - public abstract String index(); + String index(); - public abstract String row(); - - @AutoValue.Builder - public abstract static class Builder { - - public abstract Builder setDataSource(String dataSource); - - public abstract Builder setConnection(String connection); - - public abstract Builder setColumnCount(String columnCount); - - public abstract Builder setColumnLabel(String columnLabel); - - public abstract Builder setStatement(String statement); - - public abstract Builder setMetaData(String metaData); - - public abstract Builder setResultSet(String resultSet); - - public abstract Builder setBatch(String batch); - - public abstract Builder setList(String list); - - public abstract Builder setJdbcIndex(String jdbcIndex); - - public abstract Builder setIndex(String index); - - public abstract Builder setRow(String row); - - public abstract JdbcNamesConfiguration build(); + String row(); + class Builder extends ImmutableJdbcNamesConfiguration.Builder { } } diff --git a/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/LoggingConfiguration.java b/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/LoggingConfiguration.java index 8782f93fe..2a8d4824c 100644 --- a/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/LoggingConfiguration.java +++ b/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/LoggingConfiguration.java @@ -7,32 +7,30 @@ package wtf.metio.yosql.model.configuration; -import com.google.auto.value.AutoValue; +import org.immutables.value.Value; import wtf.metio.yosql.model.options.LoggingApiOptions; -@AutoValue -public abstract class LoggingConfiguration { +@Value.Immutable +public interface LoggingConfiguration { - public static Builder builder() { - return new AutoValue_LoggingConfiguration.Builder(); + static LoggingConfiguration.Builder builder() { + return new LoggingConfiguration.Builder(); } /** * @return Whether log statements should be generated */ - public final boolean shouldLog() { + default boolean shouldLog() { return LoggingApiOptions.NONE != api(); } - public abstract LoggingApiOptions api(); - - @AutoValue.Builder - public abstract static class Builder { - - public abstract Builder setApi(LoggingApiOptions api); - - public abstract LoggingConfiguration build(); + /** + * @return The logging API to use. + * @see LoggingApiOptions + */ + LoggingApiOptions api(); + class Builder extends ImmutableLoggingConfiguration.Builder { } } diff --git a/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/MethodConfiguration.java b/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/MethodConfiguration.java index 7f22f4f30..810a5d5e3 100644 --- a/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/MethodConfiguration.java +++ b/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/MethodConfiguration.java @@ -7,94 +7,54 @@ package wtf.metio.yosql.model.configuration; -import com.google.auto.value.AutoValue; +import org.immutables.value.Value; import java.util.List; -@AutoValue -public abstract class MethodConfiguration { +@Value.Immutable +public interface MethodConfiguration { - public static MethodConfiguration.Builder builder() { - return new AutoValue_MethodConfiguration.Builder(); + static MethodConfiguration.Builder builder() { + return new MethodConfiguration.Builder(); } - public abstract boolean generateStandardApi(); + boolean generateStandardApi(); - public abstract boolean generateBatchApi(); + boolean generateBatchApi(); - public abstract boolean generateRxJavaApi(); + boolean generateRxJavaApi(); - public abstract boolean generateStreamEagerApi(); + boolean generateStreamEagerApi(); - public abstract boolean generateStreamLazyApi(); + boolean generateStreamLazyApi(); - public abstract String methodBatchPrefix(); + String methodBatchPrefix(); - public abstract String methodBatchSuffix(); + String methodBatchSuffix(); - public abstract String methodStreamPrefix(); + String methodStreamPrefix(); - public abstract String methodStreamSuffix(); + String methodStreamSuffix(); - public abstract String methodRxJavaPrefix(); + String methodRxJavaPrefix(); - public abstract String methodRxJavaSuffix(); + String methodRxJavaSuffix(); - public abstract String methodLazyName(); + String methodLazyName(); - public abstract String methodEagerName(); + String methodEagerName(); - public abstract boolean methodCatchAndRethrow(); + boolean methodCatchAndRethrow(); - public abstract List allowedWritePrefixes(); + List allowedWritePrefixes(); - public abstract List allowedReadPrefixes(); + List allowedReadPrefixes(); - public abstract List allowedCallPrefixes(); + List allowedCallPrefixes(); - public abstract boolean validateMethodNamePrefixes(); - - @AutoValue.Builder - public abstract static class Builder { - - public abstract Builder setGenerateStandardApi(boolean generateStandardApi); - - public abstract Builder setGenerateBatchApi(boolean generateBatchApi); - - public abstract Builder setGenerateRxJavaApi(boolean generateRxJavaApi); - - public abstract Builder setGenerateStreamEagerApi(boolean generateStreamEagerApi); - - public abstract Builder setGenerateStreamLazyApi(boolean generateStreamLazyApi); - - public abstract Builder setMethodBatchPrefix(String value); - - public abstract Builder setMethodBatchSuffix(String value); - - public abstract Builder setMethodStreamPrefix(String value); - - public abstract Builder setMethodStreamSuffix(String value); - - public abstract Builder setMethodRxJavaPrefix(String value); - - public abstract Builder setMethodRxJavaSuffix(String value); - - public abstract Builder setMethodLazyName(String value); - - public abstract Builder setMethodEagerName(String value); - - public abstract Builder setAllowedWritePrefixes(List value); - - public abstract Builder setAllowedReadPrefixes(List value); - - public abstract Builder setAllowedCallPrefixes(List value); - - public abstract Builder setValidateMethodNamePrefixes(boolean validateMethodNamePrefixes); - - public abstract Builder setMethodCatchAndRethrow(boolean value); - - public abstract MethodConfiguration build(); + boolean validateMethodNamePrefixes(); + class Builder extends ImmutableMethodConfiguration.Builder { } } diff --git a/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/NameConfiguration.java b/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/NameConfiguration.java index feb0a7cbf..ac849682b 100644 --- a/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/NameConfiguration.java +++ b/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/NameConfiguration.java @@ -7,32 +7,22 @@ package wtf.metio.yosql.model.configuration; -import com.google.auto.value.AutoValue; +import org.immutables.value.Value; -import java.nio.file.Path; +@Value.Immutable +public interface NameConfiguration { -@AutoValue -public abstract class NameConfiguration { - - public static Builder builder() { - return new AutoValue_NameConfiguration.Builder(); + static NameConfiguration.Builder builder() { + return new NameConfiguration.Builder(); } - public abstract String utilityPackageName(); - - public abstract String converterPackageName(); - - public abstract String basePackageName(); - - @AutoValue.Builder - public abstract static class Builder { + String utilityPackageName(); - public abstract Builder setUtilityPackageName(String utilityPackageName); - public abstract Builder setConverterPackageName(String converterPackageName); - public abstract Builder setBasePackageName(String basePackageName); + String converterPackageName(); - public abstract NameConfiguration build(); + String basePackageName(); + class Builder extends ImmutableNameConfiguration.Builder { } } diff --git a/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/RepositoryConfiguration.java b/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/RepositoryConfiguration.java index 34dd4062d..93c293467 100644 --- a/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/RepositoryConfiguration.java +++ b/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/RepositoryConfiguration.java @@ -7,28 +7,20 @@ package wtf.metio.yosql.model.configuration; -import com.google.auto.value.AutoValue; +import org.immutables.value.Value; -@AutoValue -public abstract class RepositoryConfiguration { +@Value.Immutable +public interface RepositoryConfiguration { - public static Builder builder() { - return new AutoValue_RepositoryConfiguration.Builder(); + static RepositoryConfiguration.Builder builder() { + return new RepositoryConfiguration.Builder(); } - public abstract String repositoryNameSuffix(); + String repositoryNameSuffix(); - public abstract boolean repositoryGenerateInterface(); - - @AutoValue.Builder - public abstract static class Builder { - - public abstract Builder setRepositoryNameSuffix(String repositoryNameSuffix); - - public abstract Builder setRepositoryGenerateInterface(boolean repositoryGenerateInterface); - - public abstract RepositoryConfiguration build(); + boolean repositoryGenerateInterface(); + class Builder extends ImmutableRepositoryConfiguration.Builder { } } diff --git a/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/ResourceConfiguration.java b/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/ResourceConfiguration.java index 35be81a13..79f3e8e09 100644 --- a/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/ResourceConfiguration.java +++ b/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/ResourceConfiguration.java @@ -7,27 +7,21 @@ package wtf.metio.yosql.model.configuration; -import com.google.auto.value.AutoValue; +import org.immutables.value.Value; -@AutoValue -public abstract class ResourceConfiguration { +@Value.Immutable +public interface ResourceConfiguration { - public static ResourceConfiguration.Builder builder() { - return new AutoValue_ResourceConfiguration.Builder(); + static ResourceConfiguration.Builder builder() { + return new ResourceConfiguration.Builder(); } /** * @return The maximum number of threads to use while working. */ - public abstract int maxThreads(); - - @AutoValue.Builder - public abstract static class Builder { - - public abstract Builder setMaxThreads(int maxThreads); - - public abstract ResourceConfiguration build(); + int maxThreads(); + class Builder extends ImmutableResourceConfiguration.Builder { } } diff --git a/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/ResultConfiguration.java b/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/ResultConfiguration.java index 609f2a1b1..9b0e58691 100644 --- a/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/ResultConfiguration.java +++ b/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/ResultConfiguration.java @@ -7,29 +7,21 @@ package wtf.metio.yosql.model.configuration; -import com.google.auto.value.AutoValue; import com.squareup.javapoet.ClassName; +import org.immutables.value.Value; -@AutoValue -public abstract class ResultConfiguration { +@Value.Immutable +public interface ResultConfiguration { - public static Builder builder() { - return new AutoValue_ResultConfiguration.Builder(); + static ResultConfiguration.Builder builder() { + return new ResultConfiguration.Builder(); } - public abstract ClassName resultStateClass(); + ClassName resultStateClass(); - public abstract ClassName resultRowClass(); - - @AutoValue.Builder - public abstract static class Builder { - - public abstract Builder setResultStateClass(ClassName resultStateClass); - - public abstract Builder setResultRowClass(ClassName resultRowClass); - - public abstract ResultConfiguration build(); + ClassName resultRowClass(); + class Builder extends ImmutableResultConfiguration.Builder { } } diff --git a/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/RuntimeConfiguration.java b/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/RuntimeConfiguration.java index b0a778b76..1c4e8e156 100644 --- a/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/RuntimeConfiguration.java +++ b/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/RuntimeConfiguration.java @@ -7,72 +7,42 @@ package wtf.metio.yosql.model.configuration; -import com.google.auto.value.AutoValue; +import org.immutables.value.Value; -@AutoValue -public abstract class RuntimeConfiguration { +@Value.Immutable +public interface RuntimeConfiguration { - public static Builder builder() { - return new AutoValue_RuntimeConfiguration.Builder(); + static RuntimeConfiguration.Builder builder() { + return new RuntimeConfiguration.Builder(); } - public abstract FileConfiguration files(); + FileConfiguration files(); - public abstract JavaConfiguration java(); + JavaConfiguration java(); - public abstract LoggingConfiguration logging(); + LoggingConfiguration logging(); - public abstract MethodConfiguration methods(); + MethodConfiguration methods(); - public abstract NameConfiguration names(); + NameConfiguration names(); - public abstract ResourceConfiguration resources(); + ResourceConfiguration resources(); - public abstract RepositoryConfiguration repositories(); + RepositoryConfiguration repositories(); - public abstract StatementConfiguration statements(); + StatementConfiguration statements(); - public abstract VariableConfiguration variables(); + VariableConfiguration variables(); - public abstract JdbcNamesConfiguration jdbcNames(); + JdbcNamesConfiguration jdbcNames(); - public abstract RxJavaConfiguration rxJava(); + RxJavaConfiguration rxJava(); - public abstract ResultConfiguration result(); + ResultConfiguration result(); - public abstract AnnotationConfiguration annotations(); - - @AutoValue.Builder - public abstract static class Builder { - - public abstract Builder setFiles(FileConfiguration files); - - public abstract Builder setJava(JavaConfiguration java); - - public abstract Builder setLogging(LoggingConfiguration logging); - - public abstract Builder setMethods(MethodConfiguration methods); - - public abstract Builder setNames(NameConfiguration names); - - public abstract Builder setResources(ResourceConfiguration resources); - - public abstract Builder setRepositories(RepositoryConfiguration repository); - - public abstract Builder setStatements(StatementConfiguration statements); - - public abstract Builder setVariables(VariableConfiguration variables); - - public abstract Builder setJdbcNames(JdbcNamesConfiguration jdbcNames); - - public abstract Builder setRxJava(RxJavaConfiguration rxJava); - - public abstract Builder setResult(ResultConfiguration result); - - public abstract Builder setAnnotations(AnnotationConfiguration annotations); - - public abstract RuntimeConfiguration build(); + AnnotationConfiguration annotations(); + class Builder extends ImmutableRuntimeConfiguration.Builder { } } diff --git a/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/RxJavaConfiguration.java b/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/RxJavaConfiguration.java index f3cd0d0ba..317679317 100644 --- a/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/RxJavaConfiguration.java +++ b/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/RxJavaConfiguration.java @@ -7,28 +7,19 @@ package wtf.metio.yosql.model.configuration; -import com.google.auto.value.AutoValue; import com.squareup.javapoet.ClassName; +import org.immutables.value.Value; -import javax.annotation.Nullable; -import java.util.Optional; +@Value.Immutable +public interface RxJavaConfiguration { -@AutoValue -public abstract class RxJavaConfiguration { - - public static Builder builder() { - return new AutoValue_RxJavaConfiguration.Builder(); + static RxJavaConfiguration.Builder builder() { + return new RxJavaConfiguration.Builder(); } - public abstract ClassName flowStateClass(); - - @AutoValue.Builder - public abstract static class Builder { - - public abstract Builder setFlowStateClass(ClassName value); - - public abstract RxJavaConfiguration build(); + ClassName flowStateClass(); + class Builder extends ImmutableRxJavaConfiguration.Builder { } } diff --git a/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/StatementConfiguration.java b/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/StatementConfiguration.java index 123b02618..e56999812 100644 --- a/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/StatementConfiguration.java +++ b/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/StatementConfiguration.java @@ -7,26 +7,19 @@ package wtf.metio.yosql.model.configuration; -import com.google.auto.value.AutoValue; +import org.immutables.value.Value; import wtf.metio.yosql.model.options.StatementInRepositoryOptions; -@AutoValue -public abstract class StatementConfiguration { +@Value.Immutable +public interface StatementConfiguration { - public static Builder builder() { - return new AutoValue_StatementConfiguration.Builder(); + static StatementConfiguration.Builder builder() { + return new StatementConfiguration.Builder(); } - // TODO: move to RepositoryConfig? - public abstract StatementInRepositoryOptions embed(); - - @AutoValue.Builder - public abstract static class Builder { - - public abstract Builder setEmbed(StatementInRepositoryOptions targetVersion); - - public abstract StatementConfiguration build(); + StatementInRepositoryOptions embed(); + class Builder extends ImmutableStatementConfiguration.Builder { } } diff --git a/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/VariableConfiguration.java b/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/VariableConfiguration.java index 06f7444a0..1299555f2 100644 --- a/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/VariableConfiguration.java +++ b/yosql-core/src/main/java/wtf/metio/yosql/model/configuration/VariableConfiguration.java @@ -7,33 +7,25 @@ package wtf.metio.yosql.model.configuration; -import com.google.auto.value.AutoValue; +import org.immutables.value.Value; import wtf.metio.yosql.model.options.VariableTypeOptions; import javax.lang.model.element.Modifier; import java.util.List; -@AutoValue -public abstract class VariableConfiguration { +@Value.Immutable +public interface VariableConfiguration { - public static Builder builder() { - return new AutoValue_VariableConfiguration.Builder(); + static VariableConfiguration.Builder builder() { + return new VariableConfiguration.Builder(); } // TODO: align with JavaConfiguration#useVar - public abstract VariableTypeOptions variableType(); + VariableTypeOptions variableType(); - public abstract List modifiers(); - - @AutoValue.Builder - public abstract static class Builder { - - public abstract Builder setVariableType(VariableTypeOptions variableType); - - public abstract Builder setModifiers(List modifiers); - - public abstract VariableConfiguration build(); + List modifiers(); + class Builder extends ImmutableVariableConfiguration.Builder { } } diff --git a/yosql-core/src/main/java/wtf/metio/yosql/model/package-info.java b/yosql-core/src/main/java/wtf/metio/yosql/model/package-info.java index a0370c27f..a4bf5be29 100644 --- a/yosql-core/src/main/java/wtf/metio/yosql/model/package-info.java +++ b/yosql-core/src/main/java/wtf/metio/yosql/model/package-info.java @@ -7,4 +7,13 @@ /** * The model used during code generation. */ +@Value.Style( + get = {"is*", "get*"}, + init = "set*", + strictBuilder = true, + visibility = Value.Style.ImplementationVisibility.PACKAGE, + overshadowImplementation = true +) package wtf.metio.yosql.model; + +import org.immutables.value.Value; \ No newline at end of file diff --git a/yosql-core/src/test/java/wtf/metio/yosql/model/configuration/ModelConfigurationObjectMother.java b/yosql-core/src/test/java/wtf/metio/yosql/model/configuration/ModelConfigurationObjectMother.java index b129e075d..cb0f9805e 100644 --- a/yosql-core/src/test/java/wtf/metio/yosql/model/configuration/ModelConfigurationObjectMother.java +++ b/yosql-core/src/test/java/wtf/metio/yosql/model/configuration/ModelConfigurationObjectMother.java @@ -50,7 +50,7 @@ public static VariableConfiguration variableConfiguration() { public static VariableConfiguration variableConfiguration(final VariableTypeOptions options) { return VariableConfiguration.builder() - .setModifiers(List.of(Modifier.FINAL)) + .addModifiers(Modifier.FINAL) .setVariableType(options) .build(); } @@ -81,9 +81,9 @@ public static LoggingConfiguration loggingConfiguration() { public static MethodConfiguration methodConfiguration() { return MethodConfiguration.builder() - .setAllowedCallPrefixes(List.of("call")) - .setAllowedReadPrefixes(List.of("read")) - .setAllowedWritePrefixes(List.of("write")) + .addAllowedCallPrefixes("call") + .addAllowedReadPrefixes("read") + .addAllowedWritePrefixes("write") .setGenerateBatchApi(true) .setGenerateStandardApi(true) .setGenerateRxJavaApi(true) diff --git a/yosql-maven-plugin/src/main/java/wtf/metio/yosql/maven/Methods.java b/yosql-maven-plugin/src/main/java/wtf/metio/yosql/maven/Methods.java index ea5e584c2..0ff2b0916 100644 --- a/yosql-maven-plugin/src/main/java/wtf/metio/yosql/maven/Methods.java +++ b/yosql-maven-plugin/src/main/java/wtf/metio/yosql/maven/Methods.java @@ -154,9 +154,9 @@ MethodConfiguration asConfiguration() { .setMethodEagerName(methodEagerName) .setMethodLazyName(methodLazyName) .setMethodCatchAndRethrow(methodCatchAndRethrow) - .setAllowedReadPrefixes(List.of("select", "read")) // TODO: configure w/ Maven - .setAllowedWritePrefixes(List.of("insert", "update", "write")) // TODO: configure w/ Maven - .setAllowedCallPrefixes(List.of("call", "execute")) // TODO: configure w/ Maven + .addAllowedReadPrefixes("select", "read") // TODO: configure w/ Maven + .addAllowedWritePrefixes("insert", "update", "write") // TODO: configure w/ Maven + .addAllowedCallPrefixes("call", "execute") // TODO: configure w/ Maven .setValidateMethodNamePrefixes(methodValidateNamePrefixes) .build(); } diff --git a/yosql-maven-plugin/src/main/java/wtf/metio/yosql/maven/Variables.java b/yosql-maven-plugin/src/main/java/wtf/metio/yosql/maven/Variables.java index e5a3a6c42..18a4d155f 100644 --- a/yosql-maven-plugin/src/main/java/wtf/metio/yosql/maven/Variables.java +++ b/yosql-maven-plugin/src/main/java/wtf/metio/yosql/maven/Variables.java @@ -20,7 +20,7 @@ public class Variables { VariableConfiguration asConfiguration() { return VariableConfiguration.builder() - .setModifiers(List.of(Modifier.FINAL)) // TODO: configure w/ Maven + .addModifiers(Modifier.FINAL) // TODO: configure w/ Maven .setVariableType(VariableTypeOptions.TYPE) // TODO: configure w/ Maven .build(); }