@@ -50,7 +50,7 @@ public class RomeStep {
50
50
* Path to the directory with the {@code rome.json} config file, can be
51
51
* <code>null</code>, in which case the defaults are used.
52
52
*/
53
- private final String configPath ;
53
+ private String configPath ;
54
54
55
55
/**
56
56
* The language (syntax) of the input files to format. When <code>null</code> or
@@ -68,7 +68,7 @@ public class RomeStep {
68
68
* <li>json (JSON)</li>
69
69
* </ul>
70
70
*/
71
- private final String language ;
71
+ private String language ;
72
72
73
73
/**
74
74
* Path to the Rome executable. Can be <code>null</code>, but either a path to
@@ -106,8 +106,8 @@ public static String name() {
106
106
* @param downloadDir Directory where to place the downloaded executable.
107
107
* @return A new Rome step that download the executable from the network.
108
108
*/
109
- public static RomeStep . Builder withExeDownload (String version , String downloadDir ) {
110
- return new RomeStep . Builder (version , null , downloadDir );
109
+ public static RomeStep withExeDownload (String version , String downloadDir ) {
110
+ return new RomeStep (version , null , downloadDir );
111
111
}
112
112
113
113
/**
@@ -117,8 +117,8 @@ public static RomeStep.Builder withExeDownload(String version, String downloadDi
117
117
* @param pathToExe Path to the Rome executable to use.
118
118
* @return A new Rome step that format with the given executable.
119
119
*/
120
- public static RomeStep . Builder withExePath (String pathToExe ) {
121
- return new RomeStep . Builder (null , pathToExe , null );
120
+ public static RomeStep withExePath (String pathToExe ) {
121
+ return new RomeStep (null , pathToExe , null );
122
122
}
123
123
124
124
/**
@@ -217,12 +217,10 @@ private static void validateRomeExecutable(String resolvedPathToExe) {
217
217
*
218
218
* @param builder Builder with the configuration to use.
219
219
*/
220
- private RomeStep (RomeStep .Builder builder ) {
221
- this .version = builder .version != null && !builder .version .isBlank () ? builder .version : defaultVersion ();
222
- this .pathToExe = builder .pathToExe ;
223
- this .downloadDir = builder .downloadDir ;
224
- this .configPath = builder .configPath ;
225
- this .language = builder .language ;
220
+ private RomeStep (String version , String pathToExe , String downloadDir ) {
221
+ this .version = version != null && !version .isBlank () ? version : defaultVersion ();
222
+ this .pathToExe = pathToExe ;
223
+ this .downloadDir = downloadDir ;
226
224
}
227
225
228
226
/**
@@ -235,6 +233,44 @@ public FormatterStep create() {
235
233
return FormatterStep .createLazy (name (), this ::createState , State ::toFunc );
236
234
}
237
235
236
+ /**
237
+ * Sets the path to the directory with the {@code rome.json} config file. When
238
+ * no config path is set, the default configuration is used.
239
+ *
240
+ * @param configPath Config path to use. Must point to a directory which contain
241
+ * a file named {@code rome.json}.
242
+ * @return This builder instance for chaining method calls.
243
+ */
244
+ public RomeStep withConfigPath (String configPath ) {
245
+ this .configPath = configPath ;
246
+ return this ;
247
+ }
248
+
249
+ /**
250
+ * Sets the language of the files to format When no language is set, it is
251
+ * determined automatically from the file name. The following languages are
252
+ * currently supported by Rome.
253
+ *
254
+ * <ul>
255
+ * <li>js (JavaScript)</li>
256
+ * <li>jsx (JavaScript + JSX)</li>
257
+ * <li>js? (JavaScript or JavaScript + JSX, depending on the file
258
+ * extension)</li>
259
+ * <li>ts (TypeScript)</li>
260
+ * <li>tsx (TypeScript + JSX)</li>
261
+ * <li>ts? (TypeScript or TypeScript + JSX, depending on the file
262
+ * extension)</li>
263
+ * <li>json (JSON)</li>
264
+ * </ul>
265
+ *
266
+ * @param language The language of the files to format.
267
+ * @return This builder instance for chaining method calls.
268
+ */
269
+ public RomeStep withLanguage (String language ) {
270
+ this .language = language ;
271
+ return this ;
272
+ }
273
+
238
274
/**
239
275
* Resolves the Rome executable, possibly downloading it from the network, and
240
276
* creates a new state instance with the resolved executable that can format
@@ -290,88 +326,6 @@ private String resolveExe() throws IOException, InterruptedException {
290
326
}
291
327
}
292
328
293
- public final static class Builder {
294
- /** See {@link RomeStep#configPath} */
295
- private String configPath ;
296
-
297
- /** See {@link RomeStep#downloadDir} */
298
- private final String downloadDir ;
299
-
300
- /** See {@link RomeStep#language} */
301
- private String language ;
302
-
303
- /** See {@link RomeStep#pathToExe} */
304
- private final String pathToExe ;
305
-
306
- /** See {@link RomeStep#version} */
307
- private final String version ;
308
-
309
- /**
310
- * Creates a new builder for configuring a Rome step that can format code via
311
- * Rome. Either a version and and downloadDir, or a pathToExe must be given.
312
- *
313
- * @param version The version of Rome to download, see
314
- * {@link RomeStep#version}.
315
- * @param pathToExe The path to the Rome executable to use, see
316
- * {@link RomeStep#pathToExe}.
317
- * @param downloadDir The path to the download directory when downloading Rome
318
- * from the network, {@link RomeStep#downloadDir}.
319
- */
320
- private Builder (String version , String pathToExe , String downloadDir ) {
321
- this .version = version ;
322
- this .pathToExe = pathToExe ;
323
- this .downloadDir = downloadDir ;
324
- }
325
-
326
- /**
327
- * Creates a new Rome step for formatting code with Rome from the current
328
- * configuration of this builder.
329
- *
330
- * @return A new Rome step with the current configuration.
331
- */
332
- public RomeStep build () {
333
- return new RomeStep (this );
334
- }
335
-
336
- /**
337
- * Sets the path to the directory with the {@code rome.json} config file. When
338
- * no config path is set, the default configuration is used.
339
- *
340
- * @param configPath Config path to use. Must point to a directory which contain
341
- * a file named {@code rome.json}.
342
- * @return This builder instance for chaining method calls.
343
- */
344
- public Builder withConfigPath (String configPath ) {
345
- this .configPath = configPath ;
346
- return this ;
347
- }
348
-
349
- /**
350
- * Sets the language of the files to format When no language is set, it is
351
- * determined automatically from the file name. The following languages are
352
- * currently supported by Rome.
353
- *
354
- * <ul>
355
- * <li>js (JavaScript)</li>
356
- * <li>jsx (JavaScript + JSX)</li>
357
- * <li>js? (JavaScript or JavaScript + JSX, depending on the file
358
- * extension)</li>
359
- * <li>ts (TypeScript)</li>
360
- * <li>tsx (TypeScript + JSX)</li>
361
- * <li>ts? (TypeScript or TypeScript + JSX, depending on the file
362
- * extension)</li>
363
- * <li>json (JSON)</li>
364
- * </ul>
365
- *
366
- * @param language The language of the files to format.
367
- * @return This builder instance for chaining method calls.
368
- */
369
- public Builder withLanguage (String language ) {
370
- this .language = language ;
371
- return this ;
372
- }
373
- }
374
-
375
329
/**
376
330
* The internal state used by the Rome formatter. A state instance is created
377
331
* when the spotless plugin for Maven or Gradle is executed, and reused for all
0 commit comments