33
33
public class WorkflowSettings {
34
34
35
35
private static final Logger LOGGER = LoggerFactory .getLogger (WorkflowSettings .class );
36
+ public static final String DEFAULT_INPUT_SPEC = null ;
37
+ public static final String DEFAULT_OUTPUT_DIR = "." ;
38
+ public static final boolean DEFAULT_VERBOSE = false ;
39
+ public static final boolean DEFAULT_SKIP_OVERWRITE = false ;
40
+ public static final boolean DEFAULT_REMOVE_OPERATION_ID_PREFIX = false ;
41
+ public static final boolean DEFAULT_LOG_TO_STDERR = false ;
42
+ public static final boolean DEFAULT_VALIDATE_SPEC = true ;
43
+ public static final boolean DEFAULT_ENABLE_POST_PROCESS_FILE = false ;
44
+ public static final boolean DEFAULT_ENABLE_MINIMAL_UPDATE = false ;
45
+ public static final boolean DEFAULT_STRICT_SPEC_BEHAVIOR = true ;
46
+ public static final String DEFAULT_TEMPLATE_DIR = null ;
47
+ public static final String DEFAULT_TEMPLATING_ENGINE_NAME = null ;
48
+ public static final String DEFAULT_IGNORE_FILE_OVERRIDE = null ;
49
+ public static final ImmutableMap <String , String > DEFAULT_SYSTEM_PROPERTIES = ImmutableMap .copyOf (new HashMap <>());
36
50
37
51
private String inputSpec ;
38
52
private String outputDir ;
@@ -51,20 +65,77 @@ public class WorkflowSettings {
51
65
52
66
private WorkflowSettings (Builder builder ) {
53
67
this ();
54
- inputSpec = builder .inputSpec ;
55
- outputDir = builder .outputDir ;
56
- verbose = builder .verbose ;
57
- skipOverwrite = builder .skipOverwrite ;
58
- removeOperationIdPrefix = builder .removeOperationIdPrefix ;
59
- logToStderr = builder .logToStderr ;
60
- validateSpec = builder .validateSpec ;
61
- enablePostProcessFile = builder .enablePostProcessFile ;
62
- enableMinimalUpdate = builder .enableMinimalUpdate ;
63
- strictSpecBehavior = builder .strictSpecBehavior ;
64
- templateDir = builder .templateDir ;
65
- templatingEngineName = builder .templatingEngineName ;
66
- ignoreFileOverride = builder .ignoreFileOverride ;
67
- systemProperties = ImmutableMap .copyOf (builder .systemProperties );
68
+ if (builder .inputSpec == null ) {
69
+ this .inputSpec = DEFAULT_INPUT_SPEC ;
70
+ } else {
71
+ this .inputSpec = builder .inputSpec ;
72
+ }
73
+ if (builder .outputDir == null ) {
74
+ this .outputDir = DEFAULT_OUTPUT_DIR ;
75
+ } else {
76
+ this .outputDir = builder .outputDir ;
77
+ }
78
+ if (builder .verbose == null ) {
79
+ this .verbose = DEFAULT_VERBOSE ;
80
+ } else {
81
+ this .verbose = builder .verbose ;
82
+ }
83
+ if (builder .skipOverwrite == null ) {
84
+ this .skipOverwrite = DEFAULT_SKIP_OVERWRITE ;
85
+ } else {
86
+ this .skipOverwrite = builder .skipOverwrite ;
87
+ }
88
+ if (builder .removeOperationIdPrefix == null ) {
89
+ this .removeOperationIdPrefix = DEFAULT_REMOVE_OPERATION_ID_PREFIX ;
90
+ } else {
91
+ this .removeOperationIdPrefix = builder .removeOperationIdPrefix ;
92
+ }
93
+ if (builder .logToStderr == null ) {
94
+ this .logToStderr = DEFAULT_LOG_TO_STDERR ;
95
+ } else {
96
+ this .logToStderr = builder .logToStderr ;
97
+ }
98
+ if (builder .validateSpec == null ) {
99
+ this .validateSpec = DEFAULT_VALIDATE_SPEC ;
100
+ } else {
101
+ this .validateSpec = builder .validateSpec ;
102
+ }
103
+ if (builder .enablePostProcessFile == null ) {
104
+ this .enablePostProcessFile = DEFAULT_ENABLE_POST_PROCESS_FILE ;
105
+ } else {
106
+ this .enablePostProcessFile = builder .enablePostProcessFile ;
107
+ }
108
+ if (builder .enableMinimalUpdate == null ) {
109
+ this .enableMinimalUpdate = DEFAULT_ENABLE_MINIMAL_UPDATE ;
110
+ } else {
111
+ this .enableMinimalUpdate = builder .enableMinimalUpdate ;
112
+ }
113
+ if (builder .strictSpecBehavior == null ) {
114
+ this .strictSpecBehavior = DEFAULT_STRICT_SPEC_BEHAVIOR ;
115
+ } else {
116
+ this .strictSpecBehavior = builder .strictSpecBehavior ;
117
+ }
118
+ if (builder .templateDir == null ) {
119
+ this .templateDir = DEFAULT_TEMPLATE_DIR ;
120
+ } else {
121
+ this .templateDir = builder .templateDir ;
122
+ }
123
+ if (builder .templatingEngineName == null ) {
124
+ this .templatingEngineName = DEFAULT_TEMPLATING_ENGINE_NAME ;
125
+ } else {
126
+ this .templatingEngineName = builder .templatingEngineName ;
127
+ }
128
+ if (builder .ignoreFileOverride == null ) {
129
+ this .ignoreFileOverride = DEFAULT_IGNORE_FILE_OVERRIDE ;
130
+ } else {
131
+ this .ignoreFileOverride = builder .ignoreFileOverride ;
132
+ }
133
+ if (builder .systemProperties == null ) {
134
+ this .systemProperties = DEFAULT_SYSTEM_PROPERTIES ;
135
+ } else {
136
+ this .systemProperties = ImmutableMap .copyOf (builder .systemProperties );
137
+ }
138
+
68
139
}
69
140
70
141
/**
@@ -251,14 +322,14 @@ public Map<String, String> getSystemProperties() {
251
322
public static final class Builder {
252
323
private String inputSpec ;
253
324
private String outputDir ;
254
- private boolean verbose ;
255
- private boolean skipOverwrite ;
256
- private boolean removeOperationIdPrefix ;
257
- private boolean logToStderr ;
258
- private boolean validateSpec ;
259
- private boolean enablePostProcessFile ;
260
- private boolean enableMinimalUpdate ;
261
- private boolean strictSpecBehavior ;
325
+ private Boolean verbose ;
326
+ private Boolean skipOverwrite ;
327
+ private Boolean removeOperationIdPrefix ;
328
+ private Boolean logToStderr ;
329
+ private Boolean validateSpec ;
330
+ private Boolean enablePostProcessFile ;
331
+ private Boolean enableMinimalUpdate ;
332
+ private Boolean strictSpecBehavior ;
262
333
private String templateDir ;
263
334
private String templatingEngineName ;
264
335
private String ignoreFileOverride ;
@@ -270,9 +341,19 @@ private Builder() {
270
341
}
271
342
272
343
private void setDefaults (){
273
- validateSpec = true ;
274
- strictSpecBehavior = true ;
275
- outputDir = "." ;
344
+ this .inputSpec = WorkflowSettings .DEFAULT_INPUT_SPEC ;
345
+ this .outputDir = WorkflowSettings .DEFAULT_OUTPUT_DIR ;
346
+ this .verbose = WorkflowSettings .DEFAULT_VERBOSE ;
347
+ this .skipOverwrite = WorkflowSettings .DEFAULT_SKIP_OVERWRITE ;
348
+ this .removeOperationIdPrefix = WorkflowSettings .DEFAULT_REMOVE_OPERATION_ID_PREFIX ;
349
+ this .logToStderr = WorkflowSettings .DEFAULT_LOG_TO_STDERR ;
350
+ this .validateSpec = WorkflowSettings .DEFAULT_VALIDATE_SPEC ;
351
+ this .enablePostProcessFile = WorkflowSettings .DEFAULT_ENABLE_POST_PROCESS_FILE ;
352
+ this .enableMinimalUpdate = WorkflowSettings .DEFAULT_ENABLE_MINIMAL_UPDATE ;
353
+ this .strictSpecBehavior = WorkflowSettings .DEFAULT_STRICT_SPEC_BEHAVIOR ;
354
+ this .templateDir = WorkflowSettings .DEFAULT_TEMPLATE_DIR ;
355
+ this .templatingEngineName = WorkflowSettings .DEFAULT_TEMPLATING_ENGINE_NAME ;
356
+ this .ignoreFileOverride = WorkflowSettings .DEFAULT_IGNORE_FILE_OVERRIDE ;
276
357
}
277
358
278
359
/**
0 commit comments