25
25
import org .bson .codecs .RepresentationConfigurable ;
26
26
import org .bson .codecs .configuration .CodecConfigurationException ;
27
27
import org .bson .codecs .configuration .CodecRegistry ;
28
- import org .bson .codecs .record .annotations .BsonId ;
29
- import org .bson .codecs .record .annotations .BsonProperty ;
30
- import org .bson .codecs .record .annotations .BsonRepresentation ;
28
+ import org .bson .codecs .pojo .annotations .BsonCreator ;
29
+ import org .bson .codecs .pojo .annotations .BsonDiscriminator ;
30
+ import org .bson .codecs .pojo .annotations .BsonExtraElements ;
31
+ import org .bson .codecs .pojo .annotations .BsonId ;
32
+ import org .bson .codecs .pojo .annotations .BsonIgnore ;
33
+ import org .bson .codecs .pojo .annotations .BsonProperty ;
34
+ import org .bson .codecs .pojo .annotations .BsonRepresentation ;
31
35
import org .bson .diagnostics .Logger ;
32
36
import org .bson .diagnostics .Loggers ;
33
37
@@ -84,7 +88,6 @@ Object getValue(final Record record) throws InvocationTargetException, IllegalAc
84
88
return component .getAccessor ().invoke (record );
85
89
}
86
90
87
- @ SuppressWarnings ("deprecation" )
88
91
private static Codec <?> computeCodec (final List <Type > typeParameters , final RecordComponent component ,
89
92
final CodecRegistry codecRegistry ) {
90
93
var rawType = toWrapper (resolveComponentType (typeParameters , component ));
@@ -94,11 +97,9 @@ private static Codec<?> computeCodec(final List<Type> typeParameters, final Reco
94
97
: codecRegistry .get (rawType );
95
98
BsonType bsonRepresentationType = null ;
96
99
97
- if (component .isAnnotationPresent (BsonRepresentation .class )) {
98
- bsonRepresentationType = component .getAnnotation (BsonRepresentation .class ).value ();
99
- } else if (isAnnotationPresentOnField (component , org .bson .codecs .pojo .annotations .BsonRepresentation .class )) {
100
+ if (isAnnotationPresentOnField (component , BsonRepresentation .class )) {
100
101
bsonRepresentationType = getAnnotationOnField (component ,
101
- org . bson . codecs . pojo . annotations . BsonRepresentation .class ).value ();
102
+ BsonRepresentation .class ).value ();
102
103
}
103
104
if (bsonRepresentationType != null ) {
104
105
if (codec instanceof RepresentationConfigurable <?> representationConfigurable ) {
@@ -142,16 +143,11 @@ private static int getIndexOfTypeParameter(final String typeParameterName, final
142
143
recordClass .getName (), typeParameterName ));
143
144
}
144
145
145
- @ SuppressWarnings ("deprecation" )
146
146
private static String computeFieldName (final RecordComponent component ) {
147
- if (component . isAnnotationPresent ( BsonId .class )) {
147
+ if (isAnnotationPresentOnField ( component , BsonId .class )) {
148
148
return "_id" ;
149
- } else if (isAnnotationPresentOnField (component , org .bson .codecs .pojo .annotations .BsonId .class )) {
150
- return "_id" ;
151
- } else if (component .isAnnotationPresent (BsonProperty .class )) {
152
- return component .getAnnotation (BsonProperty .class ).value ();
153
- } else if (isAnnotationPresentOnField (component , org .bson .codecs .pojo .annotations .BsonProperty .class )) {
154
- return getAnnotationOnField (component , org .bson .codecs .pojo .annotations .BsonProperty .class ).value ();
149
+ } else if (isAnnotationPresentOnField (component , BsonProperty .class )) {
150
+ return getAnnotationOnField (component , BsonProperty .class ).value ();
155
151
}
156
152
return component .getName ();
157
153
}
@@ -179,14 +175,14 @@ private static <T extends Annotation> T getAnnotationOnField(final RecordCompone
179
175
}
180
176
181
177
private static void validateAnnotations (final RecordComponent component , final int index ) {
182
- validateAnnotationNotPresentOnType (component .getDeclaringRecord (), org . bson . codecs . pojo . annotations . BsonDiscriminator .class );
183
- validateAnnotationNotPresentOnConstructor (component .getDeclaringRecord (), org . bson . codecs . pojo . annotations . BsonCreator .class );
184
- validateAnnotationNotPresentOnMethod (component .getDeclaringRecord (), org . bson . codecs . pojo . annotations . BsonCreator .class );
185
- validateAnnotationNotPresentOnFieldOrAccessor (component , org . bson . codecs . pojo . annotations . BsonIgnore .class );
186
- validateAnnotationNotPresentOnFieldOrAccessor (component , org . bson . codecs . pojo . annotations . BsonExtraElements .class );
187
- validateAnnotationOnlyOnField (component , index , org . bson . codecs . pojo . annotations . BsonId .class );
188
- validateAnnotationOnlyOnField (component , index , org . bson . codecs . pojo . annotations . BsonProperty .class );
189
- validateAnnotationOnlyOnField (component , index , org . bson . codecs . pojo . annotations . BsonRepresentation .class );
178
+ validateAnnotationNotPresentOnType (component .getDeclaringRecord (), BsonDiscriminator .class );
179
+ validateAnnotationNotPresentOnConstructor (component .getDeclaringRecord (), BsonCreator .class );
180
+ validateAnnotationNotPresentOnMethod (component .getDeclaringRecord (), BsonCreator .class );
181
+ validateAnnotationNotPresentOnFieldOrAccessor (component , BsonIgnore .class );
182
+ validateAnnotationNotPresentOnFieldOrAccessor (component , BsonExtraElements .class );
183
+ validateAnnotationOnlyOnField (component , index , BsonId .class );
184
+ validateAnnotationOnlyOnField (component , index , BsonProperty .class );
185
+ validateAnnotationOnlyOnField (component , index , BsonRepresentation .class );
190
186
}
191
187
192
188
private static <T extends Annotation > void validateAnnotationNotPresentOnType (final Class <?> clazz ,
0 commit comments