/** * Creates a new {@link BasicMongoPersistentEntity} with the given {@link TypeInformation}. Will default the * collection name to the entities simple type name. * * @param typeInformation must not be {@literal null}. */ public BasicMongoPersistentEntity(TypeInformation<T> typeInformation) { super(typeInformation, MongoPersistentPropertyComparator.INSTANCE); Class<?> rawType = typeInformation.getType(); String fallback = MongoCollectionUtils.getPreferredCollectionName(rawType); if (this.isAnnotationPresent(Document.class)) { Document document = this.getRequiredAnnotation(Document.class); this.collection = StringUtils.hasText(document.collection()) ? document.collection() : fallback; this.language = StringUtils.hasText(document.language()) ? document.language() : ""; this.expression = detectExpression(document); } else { this.collection = fallback; this.language = ""; this.expression = null; } }
/** * Creates a new {@link BasicMongoPersistentEntity} with the given {@link TypeInformation}. Will default the * collection name to the entities simple type name. * * @param typeInformation must not be {@literal null}. */ public BasicMongoPersistentEntity(TypeInformation<T> typeInformation) { super(typeInformation, MongoPersistentPropertyComparator.INSTANCE); Class<?> rawType = typeInformation.getType(); String fallback = MongoCollectionUtils.getPreferredCollectionName(rawType); if (this.isAnnotationPresent(Document.class)) { Document document = this.getRequiredAnnotation(Document.class); this.collection = StringUtils.hasText(document.collection()) ? document.collection() : fallback; this.language = StringUtils.hasText(document.language()) ? document.language() : ""; this.expression = detectExpression(document); } else { this.collection = fallback; this.language = ""; this.expression = null; } }