Skip to content

Commit

Permalink
OpenAPITools#3439 Moved the default setter to the constructor of the …
Browse files Browse the repository at this point in the history
…builder. There are a few issues here:

- outputDir's default was set to "." but was overwritten by the builder.
- validateSpec was defaulted to true but was overwritten to false by the builder.
- strictSpecBehavior was defaulted to true but was overwritten to false by the builder.

A builder should not have primitive not nullable fields if there are fields containing default which are not nullable.
The main issue I migrated the default value setter to the builder is that fields can be nullable but have set a notnull default. If null is an indicator whether to set the value or not those values could never be set to null.
  • Loading branch information
Fjolnir-Dvorak committed Jul 24, 2019
1 parent 2c4fdd0 commit 01d1c05
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class WorkflowSettings {
private ImmutableMap<String, String> systemProperties;

private WorkflowSettings(Builder builder) {
setDefaults();
this();
inputSpec = builder.inputSpec;
outputDir = builder.outputDir;
verbose = builder.verbose;
Expand All @@ -72,22 +72,15 @@ private WorkflowSettings(Builder builder) {
*/
@SuppressWarnings("unused")
public WorkflowSettings() {
setDefaults();
systemProperties = ImmutableMap.of();
}

private void setDefaults(){
validateSpec = true;
strictSpecBehavior = true;
outputDir = ".";
}

public static Builder newBuilder() {
return new Builder();
}

public static Builder newBuilder(WorkflowSettings copy) {
Builder builder = new Builder();
Builder builder = newBuilder();
builder.inputSpec = copy.getInputSpec();
builder.outputDir = copy.getOutputDir();
builder.verbose = copy.isVerbose();
Expand Down Expand Up @@ -272,9 +265,16 @@ public static final class Builder {
private Map<String, String> systemProperties;

private Builder() {
setDefaults();
systemProperties = new HashMap<>();
}

private void setDefaults(){
validateSpec = true;
strictSpecBehavior = true;
outputDir = ".";
}

/**
* Sets the {@code inputSpec} and returns a reference to this Builder so that the methods can be chained together.
*
Expand Down

0 comments on commit 01d1c05

Please # to comment.