15
15
*/
16
16
package com .diffplug .spotless .generic ;
17
17
18
+ import java .io .Serializable ;
19
+
18
20
import com .diffplug .spotless .FormatterFunc ;
19
21
import com .diffplug .spotless .FormatterStep ;
20
- import com .diffplug .spotless .FormatterStepEqualityOnStateSerialization ;
22
+ import com .diffplug .spotless .SerializedFunction ;
21
23
22
24
/** Simple step which checks for consistent indentation characters. */
23
- public final class IndentStep extends FormatterStepEqualityOnStateSerialization < IndentStep > {
25
+ public final class IndentStep implements Serializable {
24
26
private static final long serialVersionUID = 1L ;
25
27
26
28
final Type type ;
@@ -31,21 +33,6 @@ private IndentStep(Type type, int numSpacesPerTab) {
31
33
this .numSpacesPerTab = numSpacesPerTab ;
32
34
}
33
35
34
- @ Override
35
- public String getName () {
36
- return "indentWith" + type .tabSpace ("Tabs" , "Spaces" );
37
- }
38
-
39
- @ Override
40
- protected IndentStep stateSupplier () {
41
- return this ;
42
- }
43
-
44
- @ Override
45
- protected FormatterFunc stateToFormatter (IndentStep state ) {
46
- return new Runtime (this )::format ;
47
- }
48
-
49
36
private static final int DEFAULT_NUM_SPACES_PER_TAB = 4 ;
50
37
51
38
public enum Type {
@@ -68,7 +55,14 @@ public FormatterStep create(int numSpacesPerTab) {
68
55
69
56
/** Creates a step which will indent with the given type of whitespace, converting between tabs and spaces at the given ratio. */
70
57
public static FormatterStep create (Type type , int numSpacesPerTab ) {
71
- return new IndentStep (type , numSpacesPerTab );
58
+ return FormatterStep .create ("indentWith" + type .tabSpace ("Tabs" , "Spaces" ),
59
+ new IndentStep (type , numSpacesPerTab ), SerializedFunction .identity (),
60
+ IndentStep ::startFormatting );
61
+ }
62
+
63
+ private FormatterFunc startFormatting () {
64
+ var runtime = new Runtime (this );
65
+ return runtime ::format ;
72
66
}
73
67
74
68
static class Runtime {
0 commit comments