Search in sources :

Example 1 with MappingValidator

use of dev.morphia.mapping.validation.MappingValidator in project morphia by mongodb.

the class Mapper method register.

/**
 * @param entityModel the model to register
 * @return the model
 * @morphia.internal
 * @since 2.3
 */
public EntityModel register(EntityModel entityModel) {
    discriminatorLookup.addModel(entityModel);
    mappedEntities.put(entityModel.getType(), entityModel);
    if (entityModel.getCollectionName() != null) {
        mappedEntitiesByCollection.computeIfAbsent(entityModel.getCollectionName(), s -> new CopyOnWriteArraySet<>()).add(entityModel);
    }
    if (!entityModel.isInterface()) {
        new MappingValidator().validate(this, entityModel);
    }
    return entityModel;
}
Also used : Document(org.bson.Document) ClassGraph(io.github.classgraph.ClassGraph) MorphiaProxy(dev.morphia.mapping.codec.references.MorphiaProxy) Arrays(java.util.Arrays) MongoCollection(com.mongodb.client.MongoCollection) Key(dev.morphia.Key) ExternalEntity(dev.morphia.annotations.experimental.ExternalEntity) Embedded(dev.morphia.annotations.Embedded) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Sofia(dev.morphia.sofia.Sofia) Map(java.util.Map) Entity(dev.morphia.annotations.Entity) LinkedList(java.util.LinkedList) ScanResult(io.github.classgraph.ScanResult) EntityModelBuilder(dev.morphia.mapping.codec.pojo.EntityModelBuilder) PropertyModel(dev.morphia.mapping.codec.pojo.PropertyModel) MappingValidator(dev.morphia.mapping.validation.MappingValidator) ClassInfo(io.github.classgraph.ClassInfo) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) CopyOnWriteArraySet(java.util.concurrent.CopyOnWriteArraySet) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) List(java.util.List) MorphiaInternal(dev.morphia.annotations.internal.MorphiaInternal) Annotation(java.lang.annotation.Annotation) EntityModel(dev.morphia.mapping.codec.pojo.EntityModel) Nullable(com.mongodb.lang.Nullable) EntityInterceptor(dev.morphia.EntityInterceptor) WriteConcern(com.mongodb.WriteConcern) CopyOnWriteArraySet(java.util.concurrent.CopyOnWriteArraySet) MappingValidator(dev.morphia.mapping.validation.MappingValidator)

Aggregations

WriteConcern (com.mongodb.WriteConcern)1 MongoCollection (com.mongodb.client.MongoCollection)1 Nullable (com.mongodb.lang.Nullable)1 EntityInterceptor (dev.morphia.EntityInterceptor)1 Key (dev.morphia.Key)1 Embedded (dev.morphia.annotations.Embedded)1 Entity (dev.morphia.annotations.Entity)1 ExternalEntity (dev.morphia.annotations.experimental.ExternalEntity)1 MorphiaInternal (dev.morphia.annotations.internal.MorphiaInternal)1 EntityModel (dev.morphia.mapping.codec.pojo.EntityModel)1 EntityModelBuilder (dev.morphia.mapping.codec.pojo.EntityModelBuilder)1 PropertyModel (dev.morphia.mapping.codec.pojo.PropertyModel)1 MorphiaProxy (dev.morphia.mapping.codec.references.MorphiaProxy)1 MappingValidator (dev.morphia.mapping.validation.MappingValidator)1 Sofia (dev.morphia.sofia.Sofia)1 ClassGraph (io.github.classgraph.ClassGraph)1 ClassInfo (io.github.classgraph.ClassInfo)1 ScanResult (io.github.classgraph.ScanResult)1 Annotation (java.lang.annotation.Annotation)1 ArrayList (java.util.ArrayList)1