Skip to content

Commit

Permalink
fix #107
Browse files Browse the repository at this point in the history
  • Loading branch information
sebhoss committed Oct 2, 2020
1 parent a748019 commit 1919f2b
Show file tree
Hide file tree
Showing 21 changed files with 209 additions and 395 deletions.
15 changes: 4 additions & 11 deletions yosql-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,10 @@
</dependency>

<dependency>
<groupId>com.google.auto.value</groupId>
<artifactId>auto-value</artifactId>
</dependency>
<dependency>
<groupId>com.google.auto.value</groupId>
<artifactId>auto-value-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.inferred</groupId>
<artifactId>freebuilder</artifactId>
<version>2.6.1</version>
<groupId>org.immutables</groupId>
<artifactId>value</artifactId>
<version>2.8.8</version>
<scope>provided</scope>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
}

}
Loading

0 comments on commit 1919f2b

Please sign in to comment.