@@ -59,16 +59,32 @@ public BufStep withPathToExe(String pathToExe) {
59
59
}
60
60
61
61
public FormatterStep create () {
62
- return FormatterStep .createLazy (name (), this ::createState , State ::toFunc );
62
+ return FormatterStep .createLazy (name (), this ::createRoundtrip , RoundtripState :: state , State ::toFunc );
63
63
}
64
64
65
- private State createState () {
65
+ private RoundtripState createRoundtrip () {
66
66
String instructions = "https://docs.buf.build/installation" ;
67
67
ForeignExe exeAbsPath = ForeignExe .nameAndVersion ("buf" , version )
68
68
.pathToExe (pathToExe )
69
69
.versionRegex (Pattern .compile ("(\\ S*)" ))
70
70
.fixCantFind ("Try following the instructions at " + instructions + ", or else tell Spotless where it is with {@code buf().pathToExe('path/to/executable')}" );
71
- return new State (this , exeAbsPath );
71
+ return new RoundtripState (version , exeAbsPath );
72
+ }
73
+
74
+ private static class RoundtripState implements Serializable {
75
+ private static final long serialVersionUID = 1L ;
76
+
77
+ final String version ;
78
+ final ForeignExe exe ;
79
+
80
+ RoundtripState (String version , ForeignExe exe ) {
81
+ this .version = version ;
82
+ this .exe = exe ;
83
+ }
84
+
85
+ private State state () {
86
+ return new State (version , exe );
87
+ }
72
88
}
73
89
74
90
@ SuppressFBWarnings ("SE_TRANSIENT_FIELD_NOT_RESTORED" )
@@ -80,8 +96,8 @@ static class State implements Serializable {
80
96
// used for executing
81
97
private transient @ Nullable List <String > args ;
82
98
83
- State (BufStep step , ForeignExe exeAbsPath ) {
84
- this .version = step . version ;
99
+ State (String version , ForeignExe exeAbsPath ) {
100
+ this .version = version ;
85
101
this .exe = Objects .requireNonNull (exeAbsPath );
86
102
}
87
103
0 commit comments