/** * @param entity * @param key * @param mappingContext * @return */ protected Field createPropertyField(@Nullable MongoPersistentEntity<?> entity, String key, MappingContext<? extends MongoPersistentEntity<?>, MongoPersistentProperty> mappingContext) { if (entity == null) { return new Field(key); } if (Field.ID_KEY.equals(key)) { return new MetadataBackedField(key, entity, mappingContext, entity.getIdProperty()); } return new MetadataBackedField(key, entity, mappingContext); }
/** * Creates a new {@link MetadataBackedField} with the given name, {@link MongoPersistentEntity} and * {@link MappingContext} with the given {@link MongoPersistentProperty}. * * @param name must not be {@literal null} or empty. * @param entity must not be {@literal null}. * @param context must not be {@literal null}. * @param property may be {@literal null}. */ public MetadataBackedField(String name, MongoPersistentEntity<?> entity, MappingContext<? extends MongoPersistentEntity<?>, MongoPersistentProperty> context, @Nullable MongoPersistentProperty property) { super(name); Assert.notNull(entity, "MongoPersistentEntity must not be null!"); this.entity = entity; this.mappingContext = context; this.path = getPath(name); this.property = path == null ? property : path.getLeafProperty(); this.association = findAssociation(); }
@Override public TypeInformation<?> getTypeHint() { MongoPersistentProperty property = getProperty(); if (property == null) { return super.getTypeHint(); } if (property.getActualType().isInterface() || java.lang.reflect.Modifier.isAbstract(property.getActualType().getModifiers())) { return ClassTypeInformation.OBJECT; } return NESTED_DOCUMENT; }
if (isPathToJavaLangClassProperty(path)) { return null;
/** * Creates a new {@link MetadataBackedField} with the given name, {@link MongoPersistentEntity} and * {@link MappingContext} with the given {@link MongoPersistentProperty}. * * @param name must not be {@literal null} or empty. * @param entity must not be {@literal null}. * @param context must not be {@literal null}. * @param property may be {@literal null}. */ public MetadataBackedField(String name, MongoPersistentEntity<?> entity, MappingContext<? extends MongoPersistentEntity<?>, MongoPersistentProperty> context, @Nullable MongoPersistentProperty property) { super(name); Assert.notNull(entity, "MongoPersistentEntity must not be null!"); this.entity = entity; this.mappingContext = context; this.path = getPath(name); this.property = path == null ? property : path.getLeafProperty(); this.association = findAssociation(); }
@Override public String getMappedKey() { return this.getPath() == null ? key : super.getMappedKey(); }
@Override public MetadataBackedField with(String name) { return new MetadataBackedField(name, entity, mappingContext, property); }
/** * Return the {@link Converter} to use for creating the mapped key of an association. Default implementation is * {@link AssociationConverter}. * * @return * @since 1.7 */ protected Converter<MongoPersistentProperty, String> getAssociationConverter() { return new AssociationConverter(getAssociation()); }
@Override public String getMappedKey() { return path == null ? name : path.toDotPath(isAssociation() ? getAssociationConverter() : getPropertyConverter()); }
/** * @param entity * @param key * @param mappingContext * @return */ protected Field createPropertyField(@Nullable MongoPersistentEntity<?> entity, String key, MappingContext<? extends MongoPersistentEntity<?>, MongoPersistentProperty> mappingContext) { return entity == null ? new Field(key) : new MetadataBackedField(key, entity, mappingContext); }
@Override public MongoPersistentEntity<?> getPropertyEntity() { MongoPersistentProperty property = getProperty(); return property == null ? null : mappingContext.getPersistentEntity(property); }
@Override public TypeInformation<?> getTypeHint() { MongoPersistentProperty property = getProperty(); if (property == null) { return super.getTypeHint(); } if (property.getActualType().isInterface() || java.lang.reflect.Modifier.isAbstract(property.getActualType().getModifiers())) { return ClassTypeInformation.OBJECT; } return NESTED_DOCUMENT; }
if (isPathToJavaLangClassProperty(path)) { return null;
@Override public MetadataBackedField with(String name) { return new MetadataBackedField(name, entity, mappingContext, property); }
@Override public String getMappedKey() { return path == null ? name : path.toDotPath(isAssociation() ? getAssociationConverter() : getPropertyConverter()); }
@Override public String getMappedKey() { return this.getPath() == null ? key : super.getMappedKey(); }
/** * Return the {@link Converter} to use for creating the mapped key of an association. Default implementation is * {@link AssociationConverter}. * * @return * @since 1.7 */ protected Converter<MongoPersistentProperty, String> getAssociationConverter() { return new AssociationConverter(getAssociation()); }
@Override public MongoPersistentEntity<?> getPropertyEntity() { MongoPersistentProperty property = getProperty(); return property == null ? null : mappingContext.getPersistentEntity(property); }