22
22
import static com .google .common .collect .ImmutableSet .toImmutableSet ;
23
23
import static com .google .common .truth .Truth .assertThat ;
24
24
import static com .google .common .truth .extensions .proto .ProtoTruth .assertThat ;
25
+ import static java .util .Objects .requireNonNull ;
25
26
26
- import com .google .auto .value .AutoValue ;
27
27
import com .google .common .collect .HashMultimap ;
28
28
import com .google .common .collect .ImmutableList ;
29
29
import com .google .common .collect .ImmutableSet ;
30
30
import com .google .common .collect .SetMultimap ;
31
31
import com .google .common .truth .extensions .proto .ProtoSubject ;
32
+ import com .google .errorprone .annotations .InlineMe ;
32
33
import com .google .javascript .jscomp .colors .Color ;
33
34
import com .google .javascript .jscomp .colors .ColorId ;
34
35
import java .util .ArrayList ;
@@ -480,14 +481,23 @@ public void avoidAddingDuplicateUnions() {
480
481
/**
481
482
* Represents a string that is stored in a StringPool, recording both its value and its offset.
482
483
*/
483
- @ AutoValue
484
- abstract static class PooledString {
485
- public abstract String getValue ();
484
+ record PooledString (String value , int poolOffset ) {
485
+ PooledString {
486
+ requireNonNull (value , "value" );
487
+ }
488
+
489
+ @ InlineMe (replacement = "this.value()" )
490
+ public String getValue () {
491
+ return value ();
492
+ }
486
493
487
- public abstract int getPoolOffset ();
494
+ @ InlineMe (replacement = "this.poolOffset()" )
495
+ public int getPoolOffset () {
496
+ return poolOffset ();
497
+ }
488
498
489
499
static PooledString create (String value , int poolOffset ) {
490
- return new AutoValue_ColorSerializerTest_PooledString (value , poolOffset );
500
+ return new PooledString (value , poolOffset );
491
501
}
492
502
}
493
503
@@ -624,43 +634,68 @@ TestColor getAxiomaticTestColor(Color axiomaticColor) {
624
634
return TestColor .create (axiomaticColor , null , poolOffset );
625
635
}
626
636
627
- /** Represents a Color that has been or will be added to the ColorSerializer. */
628
- @ AutoValue
629
- abstract static class TestColor {
630
- // The Color that will be added to the ColorSerializer.
631
- public abstract Color getColor ();
637
+ /**
638
+ * Represents a Color that has been or will be added to the ColorSerializer.
639
+ *
640
+ * @param nullableExpectedTypeProto The TypeProto we expect ColorSerializer to create for this
641
+ * Color.
642
+ * <p>For an axiomatic color this will return `null`, since those are never stored into a
643
+ * `TypeProto`. Generally test code should call `getExpectedTypeProto()` instead in order to
644
+ * get an exception if an attempt is made to serialize an axiomatic color.
645
+ */
646
+ record TestColor (
647
+ Color color , @ Nullable TypeProto nullableExpectedTypeProto , int expectedTypePointer ) {
648
+ TestColor {
649
+ requireNonNull (color , "color" );
650
+ }
632
651
633
- /**
634
- * The TypeProto we expect ColorSerializer to create for this Color.
635
- *
636
- * <p>For an axiomatic color this will return `null`, since those are never stored into a
637
- * `TypeProto`. Generally test code should call `getExpectedTypeProto()` instead in order to get
638
- * an exception if an attempt is made to serialize an axiomatic color.
639
- */
640
- public abstract @ Nullable TypeProto getNullableExpectedTypeProto ();
652
+ @ InlineMe (replacement = "this.color()" )
653
+ public Color getColor () {
654
+ return color ();
655
+ }
656
+
657
+ @ InlineMe (replacement = "this.nullableExpectedTypeProto()" )
658
+ public @ Nullable TypeProto getNullableExpectedTypeProto () {
659
+ return nullableExpectedTypeProto ();
660
+ }
661
+
662
+ @ InlineMe (replacement = "this.expectedTypePointer()" )
663
+ public int getExpectedTypePointer () {
664
+ return expectedTypePointer ();
665
+ }
666
+
667
+ // The Color that will be added to the ColorSerializer.
641
668
642
669
// The Integer we expect ColorSerializer to create for this Color.
643
- public abstract int getExpectedTypePointer ();
644
670
645
671
public TypeProto getExpectedTypeProto () {
646
672
return checkNotNull (getNullableExpectedTypeProto ());
647
673
}
648
674
649
675
static TestColor create (
650
676
Color color , @ Nullable TypeProto expectedTypeProto , int nullableExpectedTypePointer ) {
651
- return new AutoValue_ColorSerializerTest_TestColor (
652
- color , expectedTypeProto , nullableExpectedTypePointer );
677
+ return new TestColor (color , expectedTypeProto , nullableExpectedTypePointer );
653
678
}
654
679
}
655
680
656
681
/**
657
682
* Represents a color/type mismatch both as it would appear in a ColorRegistry and in a TypePool.
658
683
*/
659
- @ AutoValue
660
- abstract static class TestMismatch {
661
- public abstract String getLocationString ();
684
+ record TestMismatch (String locationString , ImmutableList <TestColor > testColors ) {
685
+ TestMismatch {
686
+ requireNonNull (locationString , "locationString" );
687
+ requireNonNull (testColors , "testColors" );
688
+ }
662
689
663
- public abstract ImmutableList <TestColor > getTestColors ();
690
+ @ InlineMe (replacement = "this.locationString()" )
691
+ public String getLocationString () {
692
+ return locationString ();
693
+ }
694
+
695
+ @ InlineMe (replacement = "this.testColors()" )
696
+ public ImmutableList <TestColor > getTestColors () {
697
+ return testColors ();
698
+ }
664
699
665
700
public List <Color > getColors () {
666
701
return getTestColors ().stream ().map (TestColor ::getColor ).collect (Collectors .toList ());
@@ -683,8 +718,7 @@ public TypePool.DebugInfo.Mismatch getExpectedMismatch() {
683
718
* order
684
719
*/
685
720
static TestMismatch create (String locationString , TestColor ... testColors ) {
686
- return new AutoValue_ColorSerializerTest_TestMismatch (
687
- locationString , ImmutableList .copyOf (testColors ));
721
+ return new TestMismatch (locationString , ImmutableList .copyOf (testColors ));
688
722
}
689
723
}
690
724
@@ -787,16 +821,22 @@ GenerateTypePoolTestResult generateTypePool() {
787
821
}
788
822
789
823
/** The result of Tester::generateTypePool() */
790
- @ AutoValue
791
- abstract static class GenerateTypePoolTestResult {
792
- public abstract TypePool getTypePool ();
824
+ record GenerateTypePoolTestResult (TypePool typePool ) {
825
+ GenerateTypePoolTestResult {
826
+ requireNonNull (typePool , "typePool" );
827
+ }
828
+
829
+ @ InlineMe (replacement = "this.typePool()" )
830
+ public TypePool getTypePool () {
831
+ return typePool ();
832
+ }
793
833
794
834
ProtoSubject assertThatTypePool () {
795
835
return assertThat (getTypePool ());
796
836
}
797
837
798
838
static GenerateTypePoolTestResult create (TypePool typePool ) {
799
- return new AutoValue_ColorSerializerTest_GenerateTypePoolTestResult (typePool );
839
+ return new GenerateTypePoolTestResult (typePool );
800
840
}
801
841
}
802
842
}
0 commit comments