/** * Reads the identifier from either the bean backing the {@link PersistentPropertyAccessor} or the source document in * case the identifier has not be populated yet. In this case the identifier is set on the bean for further reference. * * @param accessor must not be {@literal null}. * @param document must not be {@literal null}. * @param entity must not be {@literal null}. * @param path * @param evaluator * @return */ private Object readAndPopulateIdentifier(PersistentPropertyAccessor<?> accessor, DocumentAccessor document, MongoPersistentEntity<?> entity, ObjectPath path, SpELExpressionEvaluator evaluator) { Object rawId = document.getRawId(entity); if (!entity.hasIdProperty() || rawId == null) { return rawId; } MongoPersistentProperty idProperty = entity.getRequiredIdProperty(); if (idProperty.isImmutable() && entity.isConstructorArgument(idProperty)) { return rawId; } accessor.setProperty(idProperty, readIdValue(path, evaluator, idProperty, rawId)); return rawId; }
/** * Reads the identifier from either the bean backing the {@link PersistentPropertyAccessor} or the source document in * case the identifier has not be populated yet. In this case the identifier is set on the bean for further reference. * * @param accessor must not be {@literal null}. * @param document must not be {@literal null}. * @param entity must not be {@literal null}. * @param path * @param evaluator * @return */ private Object readAndPopulateIdentifier(PersistentPropertyAccessor<?> accessor, DocumentAccessor document, MongoPersistentEntity<?> entity, ObjectPath path, SpELExpressionEvaluator evaluator) { Object rawId = document.getRawId(entity); if (!entity.hasIdProperty() || rawId == null) { return rawId; } MongoPersistentProperty idProperty = entity.getRequiredIdProperty(); if (idProperty.isImmutable() && entity.isConstructorArgument(idProperty)) { return rawId; } accessor.setProperty(idProperty, readIdValue(path, evaluator, idProperty, rawId)); return rawId; }