@@ -158,6 +158,31 @@ private static final class State implements Serializable {
158
158
this .includeDraft = includeDraft ;
159
159
}
160
160
161
+ private static class JvmSupportFormatterFunc implements FormatterFunc {
162
+
163
+ final Object formatter ;
164
+ final Method formatterMethod ;
165
+
166
+ private JvmSupportFormatterFunc (Object formatter , Method formatterMethod ) {
167
+ this .formatter = formatter ;
168
+ this .formatterMethod = formatterMethod ;
169
+ }
170
+
171
+ @ Override
172
+ public String apply (String input ) throws Exception {
173
+ return apply (input , Formatter .NO_FILE_SENTINEL );
174
+ }
175
+
176
+ @ Override
177
+ public String apply (String input , File file ) throws Exception {
178
+ if (file .isAbsolute ()) {
179
+ // Cleanthat expects a relative file as input (relative to the root of the repository)
180
+ file = new File ("." , file .getPath ());
181
+ }
182
+ return (String ) formatterMethod .invoke (formatter , input , file );
183
+ }
184
+ }
185
+
161
186
FormatterFunc createFormat () {
162
187
ClassLoader classLoader = jarState .getClassLoader ();
163
188
@@ -173,21 +198,7 @@ FormatterFunc createFormat() {
173
198
throw new IllegalStateException ("Issue executing the formatter" , e );
174
199
}
175
200
176
- FormatterFunc formatterFunc = new FormatterFunc () {
177
- @ Override
178
- public String apply (String input ) throws Exception {
179
- return apply (input , Formatter .NO_FILE_SENTINEL );
180
- }
181
-
182
- @ Override
183
- public String apply (String input , File file ) throws Exception {
184
- if (file .isAbsolute ()) {
185
- // Cleanthat expects a relative file as input (relative to the root of the repository)
186
- file = new File ("." , file .getPath ());
187
- }
188
- return (String ) formatterMethod .invoke (formatter , input , file );
189
- }
190
- };
201
+ FormatterFunc formatterFunc = new JvmSupportFormatterFunc (formatter , formatterMethod );
191
202
192
203
return JVM_SUPPORT .suggestLaterVersionOnError (version , formatterFunc );
193
204
}
0 commit comments