@@ -21,13 +21,15 @@ public final class ConfigRenderOptions {
21
21
private final boolean comments ;
22
22
private final boolean formatted ;
23
23
private final boolean json ;
24
+ private final boolean showEnvVariableValues ;
24
25
25
26
private ConfigRenderOptions (boolean originComments , boolean comments , boolean formatted ,
26
- boolean json ) {
27
+ boolean json , boolean showEnvVariableValues ) {
27
28
this .originComments = originComments ;
28
29
this .comments = comments ;
29
30
this .formatted = formatted ;
30
31
this .json = json ;
32
+ this .showEnvVariableValues = showEnvVariableValues ;
31
33
}
32
34
33
35
/**
@@ -38,7 +40,7 @@ private ConfigRenderOptions(boolean originComments, boolean comments, boolean fo
38
40
* @return the default render options
39
41
*/
40
42
public static ConfigRenderOptions defaults () {
41
- return new ConfigRenderOptions (true , true , true , true );
43
+ return new ConfigRenderOptions (true , true , true , true , true );
42
44
}
43
45
44
46
/**
@@ -48,7 +50,7 @@ public static ConfigRenderOptions defaults() {
48
50
* @return the concise render options
49
51
*/
50
52
public static ConfigRenderOptions concise () {
51
- return new ConfigRenderOptions (false , false , false , true );
53
+ return new ConfigRenderOptions (false , false , false , true , true );
52
54
}
53
55
54
56
/**
@@ -64,7 +66,7 @@ public ConfigRenderOptions setComments(boolean value) {
64
66
if (value == comments )
65
67
return this ;
66
68
else
67
- return new ConfigRenderOptions (originComments , value , formatted , json );
69
+ return new ConfigRenderOptions (originComments , value , formatted , json , showEnvVariableValues );
68
70
}
69
71
70
72
/**
@@ -97,7 +99,7 @@ public ConfigRenderOptions setOriginComments(boolean value) {
97
99
if (value == originComments )
98
100
return this ;
99
101
else
100
- return new ConfigRenderOptions (value , comments , formatted , json );
102
+ return new ConfigRenderOptions (value , comments , formatted , json , showEnvVariableValues );
101
103
}
102
104
103
105
/**
@@ -122,7 +124,7 @@ public ConfigRenderOptions setFormatted(boolean value) {
122
124
if (value == formatted )
123
125
return this ;
124
126
else
125
- return new ConfigRenderOptions (originComments , comments , value , json );
127
+ return new ConfigRenderOptions (originComments , comments , value , json , showEnvVariableValues );
126
128
}
127
129
128
130
/**
@@ -150,7 +152,32 @@ public ConfigRenderOptions setJson(boolean value) {
150
152
if (value == json )
151
153
return this ;
152
154
else
153
- return new ConfigRenderOptions (originComments , comments , formatted , value );
155
+ return new ConfigRenderOptions (originComments , comments , formatted , value , showEnvVariableValues );
156
+ }
157
+
158
+ /**
159
+ * Returns options with showEnvVariableValues toggled. This controls if values set from
160
+ * environment variables are included in the rendered string.
161
+ *
162
+ * @param value
163
+ * true to include environment variable values in the render
164
+ * @return options with requested setting for environment variables
165
+ */
166
+ public ConfigRenderOptions setShowEnvVariableValues (boolean value ) {
167
+ if (value == showEnvVariableValues )
168
+ return this ;
169
+ else
170
+ return new ConfigRenderOptions (originComments , comments , formatted , json , value );
171
+ }
172
+
173
+ /**
174
+ * Returns whether the options enable rendering of environment variable values. This method is mostly used
175
+ * by the config lib internally, not by applications.
176
+ *
177
+ * @return true if environment variable values should be rendered
178
+ */
179
+ public boolean getShowEnvVariableValues () {
180
+ return showEnvVariableValues ;
154
181
}
155
182
156
183
/**
@@ -174,6 +201,8 @@ public String toString() {
174
201
sb .append ("formatted," );
175
202
if (json )
176
203
sb .append ("json," );
204
+ if (showEnvVariableValues )
205
+ sb .append ("showEnvVariableValues," );
177
206
if (sb .charAt (sb .length () - 1 ) == ',' )
178
207
sb .setLength (sb .length () - 1 );
179
208
sb .append (")" );
0 commit comments