@@ -63,10 +63,10 @@ public GofmtFormatStep withGoExecutable(String pathToExe) {
63
63
}
64
64
65
65
public FormatterStep create () {
66
- return FormatterStep .createLazy (name (), this ::createState , GofmtFormatStep . State ::toFunc );
66
+ return FormatterStep .createLazy (name (), this ::createRountrip , RoundtripState :: toEquality , EqualityState ::toFunc );
67
67
}
68
68
69
- private State createState () throws IOException , InterruptedException {
69
+ private RoundtripState createRountrip () throws IOException , InterruptedException {
70
70
String howToInstall = "gofmt is a part of standard go distribution. If spotless can't discover it automatically, " +
71
71
"you can point Spotless to the go binary with {@code pathToExe('/path/to/go')}" ;
72
72
final ForeignExe exe = ForeignExe .nameAndVersion ("go" , version )
@@ -76,18 +76,34 @@ private State createState() throws IOException, InterruptedException {
76
76
.fixWrongVersion (
77
77
"You can tell Spotless to use the version you already have with {@code gofmt('{versionFound}')}" +
78
78
"or you can install the currently specified Go version, {version}.\n " + howToInstall );
79
- return new State (this , exe );
79
+ return new RoundtripState (version , exe );
80
+ }
81
+
82
+ static class RoundtripState implements Serializable {
83
+ private static final long serialVersionUID = 1L ;
84
+
85
+ final String version ;
86
+ final ForeignExe exe ;
87
+
88
+ RoundtripState (String version , ForeignExe exe ) {
89
+ this .version = version ;
90
+ this .exe = exe ;
91
+ }
92
+
93
+ private EqualityState toEquality () {
94
+ return new EqualityState (version , exe );
95
+ }
80
96
}
81
97
82
98
@ SuppressFBWarnings ("SE_TRANSIENT_FIELD_NOT_RESTORED" )
83
- static class State implements Serializable {
99
+ static class EqualityState implements Serializable {
84
100
private static final long serialVersionUID = -1825662355363926318L ;
85
101
// used for up-to-date checks and caching
86
102
final String version ;
87
103
final transient ForeignExe exe ;
88
104
89
- public State ( GofmtFormatStep step , ForeignExe goExecutable ) {
90
- this .version = step . version ;
105
+ public EqualityState ( String version , ForeignExe goExecutable ) {
106
+ this .version = version ;
91
107
this .exe = Objects .requireNonNull (goExecutable );
92
108
}
93
109
0 commit comments