25
25
import com .google .j2objc .annotations .RetainedWith ;
26
26
import java .io .Serializable ;
27
27
import java .util .Iterator ;
28
- import javax . annotation . CheckForNull ;
28
+ import org . checkerframework . checker . nullness . qual . Nullable ;
29
29
30
30
/**
31
31
* A function from {@code A} to {@code B} with an associated <i>reverse</i> function from {@code B}
@@ -143,7 +143,7 @@ public abstract class Converter<A, B> implements Function<A, B> {
143
143
private final boolean handleNullAutomatically ;
144
144
145
145
// We lazily cache the reverse view to avoid allocating on every call to reverse().
146
- @ LazyInit @ RetainedWith @ CheckForNull private transient Converter <B , A > reverse ;
146
+ @ LazyInit @ RetainedWith private transient @ Nullable Converter <B , A > reverse ;
147
147
148
148
/** Constructor for use by subclasses. */
149
149
protected Converter () {
@@ -189,13 +189,11 @@ protected Converter() {
189
189
*
190
190
* @return the converted value; is null <i>if and only if</i> {@code a} is null
191
191
*/
192
- @ CheckForNull
193
- public final B convert (@ CheckForNull A a ) {
192
+ public final @ Nullable B convert (@ Nullable A a ) {
194
193
return correctedDoForward (a );
195
194
}
196
195
197
- @ CheckForNull
198
- B correctedDoForward (@ CheckForNull A a ) {
196
+ @ Nullable B correctedDoForward (@ Nullable A a ) {
199
197
if (handleNullAutomatically ) {
200
198
// TODO(kevinb): we shouldn't be checking for a null result at runtime. Assert?
201
199
return a == null ? null : checkNotNull (doForward (a ));
@@ -204,8 +202,7 @@ B correctedDoForward(@CheckForNull A a) {
204
202
}
205
203
}
206
204
207
- @ CheckForNull
208
- A correctedDoBackward (@ CheckForNull B b ) {
205
+ @ Nullable A correctedDoBackward (@ Nullable B b ) {
209
206
if (handleNullAutomatically ) {
210
207
// TODO(kevinb): we shouldn't be checking for a null result at runtime. Assert?
211
208
return b == null ? null : checkNotNull (doBackward (b ));
@@ -240,13 +237,11 @@ A correctedDoBackward(@CheckForNull B b) {
240
237
* LegacyConverter does violate the assumptions we make elsewhere.
241
238
*/
242
239
243
- @ CheckForNull
244
- private B unsafeDoForward (@ CheckForNull A a ) {
240
+ private @ Nullable B unsafeDoForward (@ Nullable A a ) {
245
241
return doForward (uncheckedCastNullableTToT (a ));
246
242
}
247
243
248
- @ CheckForNull
249
- private A unsafeDoBackward (@ CheckForNull B b ) {
244
+ private @ Nullable A unsafeDoBackward (@ Nullable B b ) {
250
245
return doBackward (uncheckedCastNullableTToT (b ));
251
246
}
252
247
@@ -335,14 +330,12 @@ protected B doBackward(A a) {
335
330
}
336
331
337
332
@ Override
338
- @ CheckForNull
339
- A correctedDoForward (@ CheckForNull B b ) {
333
+ @ Nullable A correctedDoForward (@ Nullable B b ) {
340
334
return original .correctedDoBackward (b );
341
335
}
342
336
343
337
@ Override
344
- @ CheckForNull
345
- B correctedDoBackward (@ CheckForNull A a ) {
338
+ @ Nullable B correctedDoBackward (@ Nullable A a ) {
346
339
return original .correctedDoForward (a );
347
340
}
348
341
@@ -352,7 +345,7 @@ public Converter<A, B> reverse() {
352
345
}
353
346
354
347
@ Override
355
- public boolean equals (@ CheckForNull Object object ) {
348
+ public boolean equals (@ Nullable Object object ) {
356
349
if (object instanceof ReverseConverter ) {
357
350
ReverseConverter <?, ?> that = (ReverseConverter <?, ?>) object ;
358
351
return this .original .equals (that .original );
@@ -417,19 +410,17 @@ protected A doBackward(C c) {
417
410
}
418
411
419
412
@ Override
420
- @ CheckForNull
421
- C correctedDoForward (@ CheckForNull A a ) {
413
+ @ Nullable C correctedDoForward (@ Nullable A a ) {
422
414
return second .correctedDoForward (first .correctedDoForward (a ));
423
415
}
424
416
425
417
@ Override
426
- @ CheckForNull
427
- A correctedDoBackward (@ CheckForNull C c ) {
418
+ @ Nullable A correctedDoBackward (@ Nullable C c ) {
428
419
return first .correctedDoBackward (second .correctedDoBackward (c ));
429
420
}
430
421
431
422
@ Override
432
- public boolean equals (@ CheckForNull Object object ) {
423
+ public boolean equals (@ Nullable Object object ) {
433
424
if (object instanceof ConverterComposition ) {
434
425
ConverterComposition <?, ?, ?> that = (ConverterComposition <?, ?, ?>) object ;
435
426
return this .first .equals (that .first ) && this .second .equals (that .second );
@@ -490,7 +481,7 @@ public final B apply(A a) {
490
481
* interchangeable.
491
482
*/
492
483
@ Override
493
- public boolean equals (@ CheckForNull Object object ) {
484
+ public boolean equals (@ Nullable Object object ) {
494
485
return super .equals (object );
495
486
}
496
487
@@ -539,7 +530,7 @@ protected A doBackward(B b) {
539
530
}
540
531
541
532
@ Override
542
- public boolean equals (@ CheckForNull Object object ) {
533
+ public boolean equals (@ Nullable Object object ) {
543
534
if (object instanceof FunctionBasedConverter ) {
544
535
FunctionBasedConverter <?, ?> that = (FunctionBasedConverter <?, ?>) object ;
545
536
return this .forwardFunction .equals (that .forwardFunction )
0 commit comments