Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Setting most generic class for source of relationship
resolves #2526
  • Loading branch information
Andy2003 committed Apr 29, 2022
commit 73261d4b2482bc5e5fb8bb9511b581413ac0fbf9
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.springframework.data.mapping.Association;
import org.springframework.data.neo4j.core.schema.Relationship;
import org.springframework.data.util.Lazy;
import org.springframework.lang.Nullable;

/**
Expand All @@ -27,13 +28,14 @@
* @author Andreas Berger
* @since 6.0
*/
final class DefaultRelationshipDescription extends Association<Neo4jPersistentProperty> implements RelationshipDescription {
final class DefaultRelationshipDescription extends Association<Neo4jPersistentProperty>
implements RelationshipDescription {

private final String type;

private final boolean dynamic;

private final NodeDescription<?> source;
private final Lazy<NodeDescription<?>> source;

private final NodeDescription<?> target;

Expand All @@ -56,7 +58,7 @@ final class DefaultRelationshipDescription extends Association<Neo4jPersistentPr
this.relationshipObverse = relationshipObverse;
this.type = type;
this.dynamic = dynamic;
this.source = getSourceForField(source, type, dynamic, target, direction, relationshipProperties);
this.source = Lazy.of(() -> getSourceForField(source, type, dynamic, target, direction, relationshipProperties));
this.fieldName = fieldName;
this.target = target;
this.direction = direction;
Expand Down Expand Up @@ -97,7 +99,7 @@ public NodeDescription<?> getTarget() {

@Override
public NodeDescription<?> getSource() {
return source;
return source.get();
}

@Override
Expand Down Expand Up @@ -150,8 +152,9 @@ public boolean equals(Object o) {
return false;
}
DefaultRelationshipDescription that = (DefaultRelationshipDescription) o;
return (isDynamic() ? getFieldName().equals(that.getFieldName()) : getType().equals(that.getType())) && getTarget().equals(that.getTarget())
&& getSource().equals(that.getSource()) && getDirection().equals(that.getDirection());
return (isDynamic() ? getFieldName().equals(that.getFieldName()) : getType().equals(that.getType()))
&& getTarget().equals(that.getTarget()) && getSource().equals(that.getSource())
&& getDirection().equals(that.getDirection());
}

@Override
Expand Down