@@ -25,30 +25,30 @@ public enum CollectionClassification {
25
25
* An Object or primitive array. Roughly follows the semantics
26
26
* of {@link #LIST}
27
27
*/
28
- ARRAY ( PluralAttribute . CollectionType . COLLECTION , true ) ,
28
+ ARRAY ,
29
29
30
30
/**
31
31
* A non-unique, unordered collection. Represented
32
32
* as {@link java.util.Collection} or {@link java.util.List}
33
33
*/
34
- BAG ( PluralAttribute . CollectionType . COLLECTION , false ) ,
34
+ BAG ,
35
35
36
36
/**
37
37
* A {@link #BAG} with a generated id for each element
38
38
*/
39
- ID_BAG ( PluralAttribute . CollectionType . COLLECTION , false ) ,
39
+ ID_BAG ,
40
40
41
41
/**
42
42
* A non-unique, ordered collection following the requirements of {@link java.util.List}
43
43
*
44
44
* @see org.hibernate.cfg.AvailableSettings#DEFAULT_LIST_SEMANTICS
45
45
*/
46
- LIST ( PluralAttribute . CollectionType . LIST , true ) ,
46
+ LIST ,
47
47
48
48
/**
49
49
* A unique, unordered collection following the requirements of {@link java.util.Set}
50
50
*/
51
- SET ( PluralAttribute . CollectionType . SET , false ) ,
51
+ SET ,
52
52
53
53
/**
54
54
* A sorted {@link #SET} using either natural sorting of the elements or a
@@ -58,7 +58,7 @@ public enum CollectionClassification {
58
58
* @see org.hibernate.annotations.SortNatural
59
59
* @see org.hibernate.annotations.SortComparator
60
60
*/
61
- SORTED_SET ( PluralAttribute . CollectionType . SET , false ) ,
61
+ SORTED_SET ,
62
62
63
63
/**
64
64
* A {@link #SET} that is ordered using an order-by fragment
@@ -69,12 +69,12 @@ public enum CollectionClassification {
69
69
* @see jakarta.persistence.OrderBy
70
70
* @see org.hibernate.annotations.SQLOrder
71
71
*/
72
- ORDERED_SET ( PluralAttribute . CollectionType . SET , false ) ,
72
+ ORDERED_SET ,
73
73
74
74
/**
75
75
* A collection following the semantics of {@link java.util.Map}
76
76
*/
77
- MAP ( PluralAttribute . CollectionType . MAP , true ) ,
77
+ MAP ,
78
78
79
79
/**
80
80
* A sorted {@link #MAP} using either natural sorting of the keys or a
@@ -84,7 +84,7 @@ public enum CollectionClassification {
84
84
* @see org.hibernate.annotations.SortNatural
85
85
* @see org.hibernate.annotations.SortComparator
86
86
*/
87
- SORTED_MAP ( PluralAttribute . CollectionType . MAP , true ) ,
87
+ SORTED_MAP ,
88
88
89
89
/**
90
90
* A {@link #MAP} that is ordered using an order-by fragment
@@ -95,22 +95,22 @@ public enum CollectionClassification {
95
95
* @see jakarta.persistence.OrderBy
96
96
* @see org.hibernate.annotations.SQLOrder
97
97
*/
98
- ORDERED_MAP ( PluralAttribute .CollectionType .MAP , true );
99
-
100
- private final PluralAttribute .CollectionType jpaClassification ;
101
- private final boolean isIndexed ;
102
-
103
- CollectionClassification (PluralAttribute .CollectionType jpaClassification , boolean isIndexed ) {
104
- this .jpaClassification = jpaClassification ;
105
- this .isIndexed = isIndexed ;
106
- }
98
+ ORDERED_MAP ;
107
99
108
100
public PluralAttribute .CollectionType toJpaClassification () {
109
- return jpaClassification ;
101
+ return switch ( this ) {
102
+ case ARRAY , BAG , ID_BAG -> PluralAttribute .CollectionType .COLLECTION ;
103
+ case LIST -> PluralAttribute .CollectionType .LIST ;
104
+ case SET , SORTED_SET , ORDERED_SET -> PluralAttribute .CollectionType .SET ;
105
+ case MAP , SORTED_MAP , ORDERED_MAP -> PluralAttribute .CollectionType .MAP ;
106
+ };
110
107
}
111
108
112
109
public boolean isIndexed () {
113
- return isIndexed ;
110
+ return switch ( this ) {
111
+ case ARRAY , LIST , MAP , SORTED_MAP , ORDERED_MAP -> true ;
112
+ default -> false ;
113
+ };
114
114
}
115
115
116
116
public boolean isRowUpdatePossible () {
0 commit comments