4
4
import org .cadixdev .at .io .AccessTransformFormat ;
5
5
import org .cadixdev .at .io .AccessTransformFormats ;
6
6
import org .jetbrains .annotations .Contract ;
7
- import org .jetbrains .annotations .NotNull ;
8
- import org .jetbrains .annotations .Nullable ;
7
+ import org .jspecify .annotations .NullMarked ;
8
+ import org .jspecify .annotations .Nullable ;
9
9
import org .openrewrite .ExecutionContext ;
10
10
11
11
import java .io .IOException ;
30
30
* @param failWithNotApplicableAccessTransformers whether restamp should fail if not all access transformers defined in {@code accessTransformers}
31
31
* were consumed by restamp.
32
32
*/
33
+ @ NullMarked
33
34
public record RestampContextConfiguration (
34
- @ NotNull ExecutionContext executionContext ,
35
- @ NotNull AccessTransformSet accessTransformSet ,
36
- @ NotNull Path sourceRoot ,
37
- @ NotNull List <Path > sourceFiles ,
38
- @ NotNull List <Path > classpath ,
35
+ ExecutionContext executionContext ,
36
+ AccessTransformSet accessTransformSet ,
37
+ Path sourceRoot ,
38
+ List <Path > sourceFiles ,
39
+ List <Path > classpath ,
39
40
boolean failWithNotApplicableAccessTransformers
40
41
) {
41
42
@@ -44,7 +45,7 @@ public record RestampContextConfiguration(
44
45
*
45
46
* @return the build instance.
46
47
*/
47
- @ NotNull
48
+
48
49
@ Contract (value = "-> new" , pure = true )
49
50
public static Builder builder () {
50
51
return new Builder ();
@@ -59,10 +60,10 @@ public static class Builder {
59
60
private @ Nullable AccessTransformSet accessTransformSet ;
60
61
private @ Nullable Path sourceRoot ;
61
62
private @ Nullable List <Path > sourceFiles ;
62
- private @ NotNull SourceFileMode sourceFileMode = SourceFileMode .MANUAL ;
63
+ private SourceFileMode sourceFileMode = SourceFileMode .MANUAL ;
63
64
private boolean failWithNotApplicableAccessTransformers = false ;
64
65
65
- private @ NotNull List <Path > classpath = Collections .emptyList ();
66
+ private List <Path > classpath = Collections .emptyList ();
66
67
67
68
/**
68
69
* Sets the execution context used by restamp for both parsing and running.
@@ -71,9 +72,9 @@ public static class Builder {
71
72
*
72
73
* @return this builder.
73
74
*/
74
- @ NotNull
75
+
75
76
@ Contract (value = "_ -> this" , mutates = "this" )
76
- public Builder executionContext (@ NotNull final ExecutionContext executionContext ) {
77
+ public Builder executionContext (final ExecutionContext executionContext ) {
77
78
this .executionContext = executionContext ;
78
79
return this ;
79
80
}
@@ -84,13 +85,12 @@ public Builder executionContext(@NotNull final ExecutionContext executionContext
84
85
*
85
86
* @param accessTransformerPath the path to the access transformers.
86
87
*
87
- * @throws IOException when something goes wrong loading the accessTransformSet
88
- *
89
88
* @return this builder.
89
+ *
90
+ * @throws IOException when something goes wrong loading the accessTransformSet
90
91
*/
91
- @ NotNull
92
92
@ Contract (value = "_ -> this" , mutates = "this" )
93
- public Builder accessTransformers (@ NotNull final Path accessTransformerPath ) throws IOException {
93
+ public Builder accessTransformers (final Path accessTransformerPath ) throws IOException {
94
94
return this .accessTransformers (accessTransformerPath , AccessTransformFormats .FML );
95
95
}
96
96
@@ -100,28 +100,25 @@ public Builder accessTransformers(@NotNull final Path accessTransformerPath) thr
100
100
* @param accessTransformerPath the path to the access transformers.
101
101
* @param accessTransformerFormat the format of the access transformers defined in the file at the provided path.
102
102
*
103
- * @throws IOException when something goes wrong loading the accessTransformSet
104
- *
105
103
* @return this builder.
104
+ *
105
+ * @throws IOException when something goes wrong loading the accessTransformSet
106
106
*/
107
- @ NotNull
108
107
@ Contract (value = "_,_ -> this" , mutates = "this" )
109
- public Builder accessTransformers (@ NotNull final Path accessTransformerPath , @ NotNull final AccessTransformFormat accessTransformerFormat ) throws IOException {
108
+ public Builder accessTransformers (final Path accessTransformerPath , final AccessTransformFormat accessTransformerFormat ) throws IOException {
110
109
this .accessTransformSet = accessTransformerFormat .read (accessTransformerPath );
111
110
return this ;
112
111
}
113
112
114
113
/**
115
- * Sets the path pointing to the file holding the access transformers .
114
+ * Sets the access transformer set to be used by restamp .
116
115
*
117
- * @param accessTransformerPath the path to the access transformers.
118
- * @param accessTransformerFormat the format of the access transformers defined in the file at the provided path.
116
+ * @param accessTransformSet the transformer set.
119
117
*
120
118
* @return this builder.
121
119
*/
122
- @ NotNull
123
120
@ Contract (value = "_,_ -> this" , mutates = "this" )
124
- public Builder accessTransformSet (@ NotNull final AccessTransformSet accessTransformSet ) {
121
+ public Builder accessTransformSet (final AccessTransformSet accessTransformSet ) {
125
122
this .accessTransformSet = AccessTransformSet .create ();
126
123
this .accessTransformSet .merge (accessTransformSet );
127
124
return this ;
@@ -134,9 +131,8 @@ public Builder accessTransformSet(@NotNull final AccessTransformSet accessTransf
134
131
*
135
132
* @return this builder.
136
133
*/
137
- @ NotNull
138
134
@ Contract (value = "_ -> this" , mutates = "this" )
139
- public Builder sourceRoot (@ NotNull final Path sourceRoot ) {
135
+ public Builder sourceRoot (final Path sourceRoot ) {
140
136
this .sourceRoot = sourceRoot ;
141
137
return this ;
142
138
}
@@ -148,9 +144,8 @@ public Builder sourceRoot(@NotNull final Path sourceRoot) {
148
144
*
149
145
* @return this builder.
150
146
*/
151
- @ NotNull
152
147
@ Contract (value = "_ -> this" , mutates = "this" )
153
- public Builder sourceFiles (@ NotNull final List <Path > sourceFiles ) {
148
+ public Builder sourceFiles (final List <Path > sourceFiles ) {
154
149
this .sourceFiles = sourceFiles ;
155
150
return this ;
156
151
}
@@ -163,7 +158,6 @@ public Builder sourceFiles(@NotNull final List<Path> sourceFiles) {
163
158
*
164
159
* @return this builder.
165
160
*/
166
- @ NotNull
167
161
@ Contract (value = "-> this" , mutates = "this" )
168
162
public Builder sourceFilesFromAccessTransformers () {
169
163
this .sourceFileMode = SourceFileMode .FROM_AT_STRICT ;
@@ -177,9 +171,9 @@ public Builder sourceFilesFromAccessTransformers() {
177
171
* If {@link #sourceFiles(List)} is called on this builder with a non-empty list, this option is meaningless.
178
172
*
179
173
* @param strict if true, restamp will fail if there are source files referenced in the ATs that don't exist.
174
+ *
180
175
* @return this builder.
181
176
*/
182
- @ NotNull
183
177
@ Contract (value = "_ -> this" , mutates = "this" )
184
178
public Builder sourceFilesFromAccessTransformers (final boolean strict ) {
185
179
this .sourceFileMode = strict ? SourceFileMode .FROM_AT_STRICT : SourceFileMode .FROM_AT_GRACEFUL ;
@@ -193,9 +187,8 @@ public Builder sourceFilesFromAccessTransformers(final boolean strict) {
193
187
*
194
188
* @return this builder.
195
189
*/
196
- @ NotNull
197
190
@ Contract (value = "_ -> this" , mutates = "this" )
198
- public Builder classpath (@ NotNull final List <Path > classpath ) {
191
+ public Builder classpath (final List <Path > classpath ) {
199
192
this .classpath = classpath ;
200
193
return this ;
201
194
}
@@ -206,7 +199,6 @@ public Builder classpath(@NotNull final List<Path> classpath) {
206
199
*
207
200
* @return this builder.
208
201
*/
209
- @ NotNull
210
202
@ Contract (value = "-> this" , mutates = "this" )
211
203
public Builder failWithNotApplicableAccessTransformers () {
212
204
this .failWithNotApplicableAccessTransformers = true ;
@@ -222,7 +214,6 @@ public Builder failWithNotApplicableAccessTransformers() {
222
214
* @throws IOException if parsing the access transformer set failed due to an {@link IOException}.
223
215
*/
224
216
@ Contract (value = "-> new" , pure = true )
225
- @ NotNull
226
217
public RestampContextConfiguration build () throws IllegalStateException {
227
218
if (this .executionContext == null ) throw new IllegalStateException ("Cannot build without an execution context" );
228
219
if (this .accessTransformSet == null ) throw new IllegalStateException ("Cannot build without access transformers!" );
0 commit comments