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