2020import com .fasterxml .jackson .databind .ObjectMapper ;
2121import com .fasterxml .jackson .databind .PropertyNamingStrategies ;
2222import com .fasterxml .jackson .datatype .jdk8 .Jdk8Module ;
23+ import com .google .common .collect .ImmutableMap ;
2324import com .hubspot .jinjava .el .JinjavaInterpreterResolver ;
2425import com .hubspot .jinjava .el .JinjavaObjectUnwrapper ;
2526import com .hubspot .jinjava .el .JinjavaProcessors ;
5354
5455@ Value .Immutable (singleton = true )
5556@ JinjavaImmutableStyle .WithStyle
56- public interface JinjavaConfig {
57+ @ Value .Style (
58+ init = "with*" ,
59+ get = { "is*" , "get*" }, // Detect 'get' and 'is' prefixes in accessor methods
60+ build = "buildImpl" , // This is an alias for keeping binary compatibility on the "build" method.
61+ visibility = Value .Style .ImplementationVisibility .PACKAGE
62+ )
63+ public class JinjavaConfig {
64+
65+ public JinjavaConfig () {}
66+
5767 @ Value .Default
58- default Charset getCharset () {
68+ public Charset getCharset () {
5969 return StandardCharsets .UTF_8 ;
6070 }
6171
6272 @ Value .Default
63- default Locale getLocale () {
73+ public Locale getLocale () {
6474 return Locale .ENGLISH ;
6575 }
6676
6777 @ Value .Default
68- default ZoneId getTimeZone () {
78+ public ZoneId getTimeZone () {
6979 return ZoneOffset .UTC ;
7080 }
7181
7282 @ Value .Default
73- default int getMaxRenderDepth () {
83+ public int getMaxRenderDepth () {
7484 return 10 ;
7585 }
7686
7787 @ Value .Default
78- default long getMaxOutputSize () {
88+ public long getMaxOutputSize () {
7989 return 0 ;
8090 }
8191
8292 @ Value .Default
83- default boolean isTrimBlocks () {
93+ public boolean isTrimBlocks () {
8494 return false ;
8595 }
8696
8797 @ Value .Default
88- default boolean isLstripBlocks () {
98+ public boolean isLstripBlocks () {
8999 return false ;
90100 }
91101
92102 @ Value .Default
93- default boolean isEnableRecursiveMacroCalls () {
103+ public boolean isEnableRecursiveMacroCalls () {
94104 return false ;
95105 }
96106
97107 @ Value .Default
98- default int getMaxMacroRecursionDepth () {
108+ public int getMaxMacroRecursionDepth () {
99109 return 0 ;
100110 }
101111
102- Map <Library , Set <String >> getDisabled ();
112+ @ Value .Default
113+ public Map <Library , Set <String >> getDisabled () {
114+ return ImmutableMap .of ();
115+ }
103116
104117 @ Value .Default
105- default boolean isFailOnUnknownTokens () {
118+ public boolean isFailOnUnknownTokens () {
106119 return false ;
107120 }
108121
109122 @ Value .Default
110- default boolean isNestedInterpretationEnabled () {
123+ public boolean isNestedInterpretationEnabled () {
111124 return false ; // Default changed to false in 3.0
112125 }
113126
114127 @ Value .Default
115- default RandomNumberGeneratorStrategy getRandomNumberGeneratorStrategy () {
128+ public RandomNumberGeneratorStrategy getRandomNumberGeneratorStrategy () {
116129 return RandomNumberGeneratorStrategy .THREAD_LOCAL ;
117130 }
118131
119132 @ Value .Default
120- default boolean isValidationMode () {
133+ public boolean isValidationMode () {
121134 return false ;
122135 }
123136
124137 @ Value .Default
125- default long getMaxStringLength () {
138+ public long getMaxStringLength () {
126139 return getMaxOutputSize ();
127140 }
128141
129142 @ Value .Default
130- default int getMaxListSize () {
143+ public int getMaxListSize () {
131144 return Integer .MAX_VALUE ;
132145 }
133146
134147 @ Value .Default
135- default int getMaxMapSize () {
148+ public int getMaxMapSize () {
136149 return Integer .MAX_VALUE ;
137150 }
138151
139152 @ Value .Default
140- default int getRangeLimit () {
153+ public int getRangeLimit () {
141154 return DEFAULT_RANGE_LIMIT ;
142155 }
143156
144157 @ Value .Default
145- default int getMaxNumDeferredTokens () {
158+ public int getMaxNumDeferredTokens () {
146159 return 1000 ;
147160 }
148161
149162 @ Value .Default
150- default InterpreterFactory getInterpreterFactory () {
163+ public InterpreterFactory getInterpreterFactory () {
151164 return new JinjavaInterpreterFactory ();
152165 }
153166
154167 @ Value .Default
155- default DateTimeProvider getDateTimeProvider () {
168+ public DateTimeProvider getDateTimeProvider () {
156169 return new CurrentDateTimeProvider ();
157170 }
158171
159172 @ Value .Default
160- default TokenScannerSymbols getTokenScannerSymbols () {
173+ public TokenScannerSymbols getTokenScannerSymbols () {
161174 return new DefaultTokenScannerSymbols ();
162175 }
163176
164177 @ Value .Default
165- default AllowlistMethodValidator getMethodValidator () {
178+ public AllowlistMethodValidator getMethodValidator () {
166179 return AllowlistMethodValidator .DEFAULT ;
167180 }
168181
169182 @ Value .Default
170- default AllowlistReturnTypeValidator getReturnTypeValidator () {
183+ public AllowlistReturnTypeValidator getReturnTypeValidator () {
171184 return AllowlistReturnTypeValidator .DEFAULT ;
172185 }
173186
174187 @ Value .Default
175- default ELResolver getElResolver () {
188+ public ELResolver getElResolver () {
176189 return isDefaultReadOnlyResolver ()
177190 ? JinjavaInterpreterResolver .DEFAULT_RESOLVER_READ_ONLY
178191 : JinjavaInterpreterResolver .DEFAULT_RESOLVER_READ_WRITE ;
179192 }
180193
181194 @ Value .Default
182- default boolean isDefaultReadOnlyResolver () {
195+ public boolean isDefaultReadOnlyResolver () {
183196 return true ;
184197 }
185198
186199 @ Value .Default
187- default ExecutionMode getExecutionMode () {
200+ public ExecutionMode getExecutionMode () {
188201 return DefaultExecutionMode .instance ();
189202 }
190203
191204 @ Value .Default
192- default LegacyOverrides getLegacyOverrides () {
205+ public LegacyOverrides getLegacyOverrides () {
193206 return LegacyOverrides .THREE_POINT_0 ;
194207 }
195208
196209 @ Value .Default
197- default boolean getEnablePreciseDivideFilter () {
210+ public boolean getEnablePreciseDivideFilter () {
198211 return false ;
199212 }
200213
201214 @ Value .Default
202- default boolean isEnableFilterChainOptimization () {
215+ public boolean isEnableFilterChainOptimization () {
203216 return false ;
204217 }
205218
206219 @ Value .Default
207- default ObjectMapper getObjectMapper () {
220+ public ObjectMapper getObjectMapper () {
208221 ObjectMapper objectMapper = new ObjectMapper ().registerModule (new Jdk8Module ());
209222 if (getLegacyOverrides ().isUseSnakeCasePropertyNaming ()) {
210223 objectMapper .setPropertyNamingStrategy (PropertyNamingStrategies .SNAKE_CASE );
@@ -213,42 +226,47 @@ default ObjectMapper getObjectMapper() {
213226 }
214227
215228 @ Value .Default
216- default ObjectUnwrapper getObjectUnwrapper () {
229+ public ObjectUnwrapper getObjectUnwrapper () {
217230 return new JinjavaObjectUnwrapper ();
218231 }
219232
220233 @ Value .Derived
221- default Features getFeatures () {
234+ public Features getFeatures () {
222235 return new Features (getFeatureConfig ());
223236 }
224237
225238 @ Value .Default
226- default FeatureConfig getFeatureConfig () {
239+ public FeatureConfig getFeatureConfig () {
227240 return FeatureConfig .newBuilder ().build ();
228241 }
229242
230243 @ Value .Default
231- default JinjavaProcessors getProcessors () {
244+ public JinjavaProcessors getProcessors () {
232245 return JinjavaProcessors .newBuilder ().build ();
233246 }
234247
235248 @ Deprecated
236- default BiConsumer <Node , JinjavaInterpreter > getNodePreProcessor () {
249+ public BiConsumer <Node , JinjavaInterpreter > getNodePreProcessor () {
237250 return getProcessors ().getNodePreProcessor ();
238251 }
239252
240253 @ Deprecated
241- default boolean isIterateOverMapKeys () {
254+ public boolean isIterateOverMapKeys () {
242255 return getLegacyOverrides ().isIterateOverMapKeys ();
243256 }
244257
245- class Builder extends ImmutableJinjavaConfig .Builder {}
258+ public static class Builder extends ImmutableJinjavaConfig .Builder {
259+
260+ public JinjavaConfig build () {
261+ return super .buildImpl ();
262+ }
263+ }
246264
247- static Builder builder () {
265+ public static Builder builder () {
248266 return new Builder ();
249267 }
250268
251- static Builder newBuilder () {
269+ public static Builder newBuilder () {
252270 return builder ();
253271 }
254272}
0 commit comments