20
20
import com .google .common .collect .ImmutableMap ;
21
21
import com .google .common .collect .ImmutableSet ;
22
22
23
- import org .checkerframework .checker .nullness .qual .NonNull ;
23
+ import org .checkerframework .checker .nullness .qual .Nullable ;
24
24
import org .hamcrest .Matcher ;
25
25
import org .junit .jupiter .api .Test ;
26
26
@@ -81,7 +81,8 @@ class ImmutableBeanTest {
81
81
throw new AssertionError ("expected error, got " + v );
82
82
} catch (IllegalArgumentException e ) {
83
83
assertThat (e .getMessage (),
84
- is ("property 'IntSansDefault' is required and has no default value" ));
84
+ is ("property 'org.apache.calcite.util.ImmutableBeanTest$Bean2#IntSansDefault'"
85
+ + " is required and has no default value" ));
85
86
}
86
87
assertThat (b .withIntSansDefault (4 ).getIntSansDefault (), is (4 ));
87
88
@@ -96,8 +97,8 @@ class ImmutableBeanTest {
96
97
throw new AssertionError ("expected error, got " + v );
97
98
} catch (IllegalArgumentException e ) {
98
99
assertThat (e .getMessage (),
99
- is ("property 'BooleanSansDefault' is required and has no default "
100
- + "value" ));
100
+ is ("property 'org.apache.calcite.util.ImmutableBeanTest$Bean2# BooleanSansDefault'"
101
+ + " is required and has no default value" ));
101
102
}
102
103
assertThat (b .withBooleanSansDefault (false ).isBooleanSansDefault (),
103
104
is (false ));
@@ -115,8 +116,8 @@ class ImmutableBeanTest {
115
116
throw new AssertionError ("expected error, got " + v );
116
117
} catch (IllegalArgumentException e ) {
117
118
assertThat (e .getMessage (),
118
- is ("property 'StringSansDefault' is required and has no default "
119
- + "value" ));
119
+ is ("property 'org.apache.calcite.util.ImmutableBeanTest$Bean2# StringSansDefault'"
120
+ + " is required and has no default value" ));
120
121
}
121
122
assertThat (b .withStringSansDefault ("a" ).getStringSansDefault (), is ("a" ));
122
123
@@ -126,7 +127,8 @@ class ImmutableBeanTest {
126
127
throw new AssertionError ("expected error, got " + v );
127
128
} catch (IllegalArgumentException e ) {
128
129
assertThat (e .getMessage (),
129
- is ("property 'NonnullString' is required and has no default value" ));
130
+ is ("property 'org.apache.calcite.util.ImmutableBeanTest$Bean2#NonnullString'"
131
+ + " is required and has no default value" ));
130
132
}
131
133
assertThat (b .withNonnullString ("a" ).getNonnullString (), is ("a" ));
132
134
@@ -564,42 +566,42 @@ interface Bean2 {
564
566
boolean isBooleanSansDefault ();
565
567
Bean2 withBooleanSansDefault (boolean x );
566
568
567
- @ ImmutableBeans .Property ( required = true )
569
+ @ ImmutableBeans .Property
568
570
String getStringSansDefault ();
569
571
Bean2 withStringSansDefault (String x );
570
572
571
573
@ ImmutableBeans .Property
572
- String getOptionalString ();
573
- Bean2 withOptionalString (String s );
574
+ @ Nullable String getOptionalString ();
575
+ Bean2 withOptionalString (@ Nullable String s );
574
576
575
- /** Property is required because it has 'Nonnull' annotation. */
577
+ /** Property is required because its return type does not have Nullable annotation. */
576
578
@ ImmutableBeans .Property
577
- @ NonNull String getNonnullString ();
579
+ String getNonnullString ();
578
580
Bean2 withNonnullString (String s );
579
581
580
582
@ ImmutableBeans .Property
581
583
@ ImmutableBeans .StringDefault ("abc" )
582
- @ NonNull String getStringWithDefault ();
583
- Bean2 withStringWithDefault (String s );
584
+ String getStringWithDefault ();
585
+ Bean2 withStringWithDefault (@ Nullable String s );
584
586
585
587
@ ImmutableBeans .Property
586
588
@ ImmutableBeans .NullDefault
587
- String getStringWithNullDefault ();
588
- Bean2 withStringWithNullDefault (String s );
589
+ @ Nullable String getStringWithNullDefault ();
590
+ Bean2 withStringWithNullDefault (@ Nullable String s );
589
591
590
592
@ ImmutableBeans .Property
591
593
@ ImmutableBeans .EnumDefault ("RED" )
592
- @ NonNull Color getColorWithDefault ();
593
- Bean2 withColorWithDefault (Color color );
594
+ Color getColorWithDefault ();
595
+ Bean2 withColorWithDefault (@ Nullable Color color );
594
596
595
597
@ ImmutableBeans .Property
596
598
@ ImmutableBeans .NullDefault
597
- Color getColorWithNullDefault ();
598
- Bean2 withColorWithNullDefault (Color color );
599
+ @ Nullable Color getColorWithNullDefault ();
600
+ Bean2 withColorWithNullDefault (@ Nullable Color color );
599
601
600
602
@ ImmutableBeans .Property ()
601
- Color getColorOptional ();
602
- Bean2 withColorOptional (Color color );
603
+ @ Nullable Color getColorOptional ();
604
+ Bean2 withColorOptional (@ Nullable Color color );
603
605
}
604
606
605
607
/** Red, blue, green. */
@@ -638,33 +640,33 @@ public interface SubBean extends MyBean {
638
640
/** A bean that has collection-valued properties. */
639
641
public interface CollectionBean {
640
642
@ ImmutableBeans .Property (makeImmutable = false )
641
- List <String > list ();
643
+ @ Nullable List <String > list ();
642
644
643
- CollectionBean withList (List <String > list );
645
+ CollectionBean withList (@ Nullable List <String > list );
644
646
645
647
@ ImmutableBeans .Property (makeImmutable = true )
646
- List <String > immutableList ();
648
+ @ Nullable List <String > immutableList ();
647
649
648
- CollectionBean withImmutableList (List <String > list );
650
+ CollectionBean withImmutableList (@ Nullable List <String > list );
649
651
650
652
@ ImmutableBeans .Property (makeImmutable = false )
651
- Set <String > set ();
653
+ @ Nullable Set <String > set ();
652
654
653
- CollectionBean withSet (Set <String > set );
655
+ CollectionBean withSet (@ Nullable Set <String > set );
654
656
655
657
@ ImmutableBeans .Property (makeImmutable = true )
656
- Set <String > immutableSet ();
658
+ @ Nullable Set <String > immutableSet ();
657
659
658
- CollectionBean withImmutableSet (Set <String > set );
660
+ CollectionBean withImmutableSet (@ Nullable Set <String > set );
659
661
660
662
@ ImmutableBeans .Property (makeImmutable = false )
661
- Map <String , Integer > map ();
663
+ @ Nullable Map <String , Integer > map ();
662
664
663
- CollectionBean withMap (Map <String , Integer > map );
665
+ CollectionBean withMap (@ Nullable Map <String , Integer > map );
664
666
665
667
@ ImmutableBeans .Property (makeImmutable = true )
666
- Map <String , Integer > immutableMap ();
668
+ @ Nullable Map <String , Integer > immutableMap ();
667
669
668
- CollectionBean withImmutableMap (Map <String , Integer > map );
670
+ CollectionBean withImmutableMap (@ Nullable Map <String , Integer > map );
669
671
}
670
672
}
0 commit comments