public Document mapSchema(Document jsonSchema, Class<?> type) { Assert.notNull(jsonSchema, "Schema must not be null!"); Assert.notNull(type, "Type must not be null! Please consider Object.class."); Assert.isTrue(jsonSchema.containsKey($JSON_SCHEMA), () -> String.format("Document does not contain $jsonSchema field. Found %s.", jsonSchema)); if (Object.class.equals(type)) { return new Document(jsonSchema); } return new Document($JSON_SCHEMA, mapSchemaObject(mappingContext.getPersistentEntity(type), jsonSchema.get($JSON_SCHEMA, Document.class))); }
private Document mapProperty(@Nullable PersistentEntity<?, MongoPersistentProperty> entity, String sourceFieldName, Document source) { Document sink = new Document(source); if (entity != null && sink.containsKey(Type.objectType().representation())) { MongoPersistentProperty property = entity.getPersistentProperty(sourceFieldName); if (property != null && property.isEntity()) { sink = mapSchemaObject(mappingContext.getPersistentEntity(property.getActualType()), source); } } return mapEnumValuesIfNecessary(sink); }
public Document mapSchema(Document jsonSchema, Class<?> type) { Assert.notNull(jsonSchema, "Schema must not be null!"); Assert.notNull(type, "Type must not be null! Please consider Object.class."); Assert.isTrue(jsonSchema.containsKey($JSON_SCHEMA), () -> String.format("Document does not contain $jsonSchema field. Found %s.", jsonSchema)); if (Object.class.equals(type)) { return new Document(jsonSchema); } return new Document($JSON_SCHEMA, mapSchemaObject(mappingContext.getPersistentEntity(type), jsonSchema.get($JSON_SCHEMA, Document.class))); }
private Document mapProperty(@Nullable PersistentEntity<?, MongoPersistentProperty> entity, String sourceFieldName, Document source) { Document sink = new Document(source); if (entity != null && sink.containsKey(Type.objectType().representation())) { MongoPersistentProperty property = entity.getPersistentProperty(sourceFieldName); if (property != null && property.isEntity()) { sink = mapSchemaObject(mappingContext.getPersistentEntity(property.getActualType()), source); } } return mapEnumValuesIfNecessary(sink); }