use of org.bson.codecs.pojo.annotations.BsonId in project mongo-java-driver by mongodb.
the class ConventionAnnotationImpl method processPropertyAnnotations.
private void processPropertyAnnotations(final ClassModelBuilder<?> classModelBuilder, final PropertyModelBuilder<?> propertyModelBuilder) {
for (Annotation annotation : propertyModelBuilder.getReadAnnotations()) {
if (annotation instanceof BsonProperty) {
BsonProperty bsonProperty = (BsonProperty) annotation;
if (!"".equals(bsonProperty.value())) {
propertyModelBuilder.readName(bsonProperty.value());
}
propertyModelBuilder.discriminatorEnabled(bsonProperty.useDiscriminator());
if (propertyModelBuilder.getName().equals(classModelBuilder.getIdPropertyName())) {
classModelBuilder.idPropertyName(null);
}
} else if (annotation instanceof BsonId) {
classModelBuilder.idPropertyName(propertyModelBuilder.getName());
} else if (annotation instanceof BsonIgnore) {
propertyModelBuilder.readName(null);
} else if (annotation instanceof BsonRepresentation) {
BsonRepresentation bsonRepresentation = (BsonRepresentation) annotation;
BsonType bsonRep = bsonRepresentation.value();
propertyModelBuilder.bsonRepresentation(bsonRep);
}
}
for (Annotation annotation : propertyModelBuilder.getWriteAnnotations()) {
if (annotation instanceof BsonProperty) {
BsonProperty bsonProperty = (BsonProperty) annotation;
if (!"".equals(bsonProperty.value())) {
propertyModelBuilder.writeName(bsonProperty.value());
}
} else if (annotation instanceof BsonIgnore) {
propertyModelBuilder.writeName(null);
}
}
}
Aggregations