Package org.neo4j.cypherdsl.core
Class RelationshipBase<S extends NodeBase<?>,E extends NodeBase<?>,SELF extends RelationshipBase<S,E,SELF>>
- java.lang.Object
-
- org.neo4j.cypherdsl.core.RelationshipBase<S,E,SELF>
-
- Type Parameters:
S
- The type at the start of the relationshipE
- The type at the pointy end of the relationshipSELF
- The type of the persistent relationship itself
- All Implemented Interfaces:
ExposesProperties<Relationship>
,ExposesRelationships<RelationshipChain>
,Named
,PatternElement
,PropertyContainer
,Relationship
,RelationshipPattern
,Visitable
@API(status=EXPERIMENTAL, since="2021.1.0") public abstract class RelationshipBase<S extends NodeBase<?>,E extends NodeBase<?>,SELF extends RelationshipBase<S,E,SELF>> extends java.lang.Object implements Relationship
This is the base class for all relationships. It can be used with generics, specifying valid start and end nodes. This is useful when using it as a base class for a static meta model.- Since:
- 2021.1.0
- Author:
- Michael J. Simons
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.neo4j.cypherdsl.core.Relationship
Relationship.Details, Relationship.Direction
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
RelationshipBase(SymbolicName symbolicName, Node start, java.lang.String type, Properties properties, Node end)
Always creates a relationship from start to end (left to right).protected
RelationshipBase(S start, java.lang.String type, E end)
Always creates a relationship from start to end (left to right).
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
accept(Visitor visitor)
Condition
asCondition()
Transform this pattern into a condition.Relationship.Details
getDetails()
The details contains the types, properties and cardinality.Node
getLeft()
SymbolicName
getRequiredSymbolicName()
protected java.lang.String
getRequiredType()
Node
getRight()
java.util.Optional<SymbolicName>
getSymbolicName()
Relationship
inverse()
Creates a new relationship, inverting the direction but keeping the semantics intact ((a) --> (b)
becomes(b) <-- (a)
).Relationship
length(java.lang.Integer minimum, java.lang.Integer maximum)
Creates a new relationship with a new lengthRelationship
max(java.lang.Integer maximum)
Creates a new relationship with a new maximum lengthRelationship
min(java.lang.Integer minimum)
Creates a new relationship with a new minimum lengthOperation
mutate(MapExpression properties)
Creates anOperation
mutating the properties of this container to a new value.Operation
mutate(Parameter parameter)
Creates anOperation
mutating the properties of this container to a new value.SELF
named(java.lang.String newSymbolicName)
Creates a copy of this relationship with a new symbolic name.abstract SELF
named(SymbolicName newSymbolicName)
This method needs to be implemented to provide new, type safe instances of this relationship.MapProjection
project(java.lang.Object... entries)
Creates a map projection based on this container.MapProjection
project(java.util.List<java.lang.Object> entries)
Unwraps the list of entries into an array before creating a projection out of it.Property
property(java.lang.String name)
Creates a newProperty
associated with this property container.Property
property(java.lang.String... names)
Property
property(Expression lookup)
Creates a newProperty
associated with this property container.RelationshipChain
relationshipBetween(Node other, java.lang.String... types)
Starts building an undirected relationship between thisnode
and theother
.RelationshipChain
relationshipFrom(Node other, java.lang.String... types)
Starts building an incoming relationship starting at theother
node
.RelationshipChain
relationshipTo(Node other, java.lang.String... types)
Starts building an outgoing relationship to theother
node
.Relationship
unbounded()
Creates a new relationship with an unbound length minimum lengthSELF
withProperties(java.lang.Object... keysAndValues)
Creates a a copy of this property container with additional properties.SELF
withProperties(java.util.Map<java.lang.String,java.lang.Object> newProperties)
Creates a a copy of this property container with additional properties.abstract SELF
withProperties(MapExpression newProperties)
This method needs to be implemented to provide new, type safe instances of this relationship.
-
-
-
Constructor Detail
-
RelationshipBase
protected RelationshipBase(S start, java.lang.String type, E end)
Always creates a relationship from start to end (left to right).- Parameters:
start
- start nodeend
- end nodetype
- type of the relationship
-
RelationshipBase
protected RelationshipBase(SymbolicName symbolicName, Node start, java.lang.String type, Properties properties, Node end)
Always creates a relationship from start to end (left to right).- Parameters:
symbolicName
- an optional symbolic namestart
- start nodeproperties
- The properties for the relationshipend
- end nodetype
- type of the relationship
-
-
Method Detail
-
named
public final SELF named(java.lang.String newSymbolicName)
Description copied from interface:Relationship
Creates a copy of this relationship with a new symbolic name.- Specified by:
named
in interfaceRelationship
- Specified by:
named
in interfaceRelationshipPattern
- Parameters:
newSymbolicName
- the new symbolic name.- Returns:
- The new relationship.
-
named
public abstract SELF named(SymbolicName newSymbolicName)
This method needs to be implemented to provide new, type safe instances of this relationship.- Specified by:
named
in interfaceRelationship
- Parameters:
newSymbolicName
- the new symbolic name.- Returns:
- A new relationship
-
withProperties
public final SELF withProperties(java.lang.Object... keysAndValues)
Description copied from interface:ExposesProperties
Creates a a copy of this property container with additional properties. Creates a property container without properties when no properties are passed to this method.- Specified by:
withProperties
in interfaceExposesProperties<S extends NodeBase<?>>
- Parameters:
keysAndValues
- A list of key and values. Must be an even number, with alternatingString
andExpression
.- Returns:
- The new property container.
-
withProperties
public final SELF withProperties(java.util.Map<java.lang.String,java.lang.Object> newProperties)
Description copied from interface:ExposesProperties
Creates a a copy of this property container with additional properties.- Specified by:
withProperties
in interfaceExposesProperties<S extends NodeBase<?>>
- Parameters:
newProperties
- A map with the new properties- Returns:
- The new property container.
-
withProperties
public abstract SELF withProperties(MapExpression newProperties)
This method needs to be implemented to provide new, type safe instances of this relationship.- Specified by:
withProperties
in interfaceExposesProperties<S extends NodeBase<?>>
- Parameters:
newProperties
- the new properties (can be null to remove exiting properties).- Returns:
- A new relationship
-
getLeft
public final Node getLeft()
- Specified by:
getLeft
in interfaceRelationship
-
getRequiredType
protected final java.lang.String getRequiredType()
-
getRight
public final Node getRight()
- Specified by:
getRight
in interfaceRelationship
-
getDetails
public final Relationship.Details getDetails()
Description copied from interface:Relationship
The details contains the types, properties and cardinality.- Specified by:
getDetails
in interfaceRelationship
- Returns:
- A wrapper around the details of this relationship.
-
unbounded
public final Relationship unbounded()
Description copied from interface:Relationship
Creates a new relationship with an unbound length minimum length- Specified by:
unbounded
in interfaceRelationship
- Returns:
- the new relationship
-
min
public final Relationship min(java.lang.Integer minimum)
Description copied from interface:Relationship
Creates a new relationship with a new minimum length- Specified by:
min
in interfaceRelationship
- Parameters:
minimum
- the new minimum- Returns:
- the new relationship
-
max
public final Relationship max(java.lang.Integer maximum)
Description copied from interface:Relationship
Creates a new relationship with a new maximum length- Specified by:
max
in interfaceRelationship
- Parameters:
maximum
- the new maximum- Returns:
- the new relationship
-
length
public final Relationship length(java.lang.Integer minimum, java.lang.Integer maximum)
Description copied from interface:Relationship
Creates a new relationship with a new length- Specified by:
length
in interfaceRelationship
- Parameters:
minimum
- the new minimummaximum
- the new maximum- Returns:
- the new relationship
-
inverse
public final Relationship inverse()
Description copied from interface:Relationship
Creates a new relationship, inverting the direction but keeping the semantics intact ((a) --> (b)
becomes(b) <-- (a)
). A symbolic name will be removed from this relationship if any, as the it wouldn't be the same pattern to match against.- Specified by:
inverse
in interfaceRelationship
- Returns:
- the new relationship
-
getSymbolicName
public final java.util.Optional<SymbolicName> getSymbolicName()
- Specified by:
getSymbolicName
in interfaceNamed
- Returns:
- An optional symbolic name.
-
getRequiredSymbolicName
public final SymbolicName getRequiredSymbolicName()
- Specified by:
getRequiredSymbolicName
in interfaceNamed
- Returns:
- A symbolic name
-
relationshipTo
public final RelationshipChain relationshipTo(Node other, java.lang.String... types)
Description copied from interface:ExposesRelationships
Starts building an outgoing relationship to theother
node
.- Specified by:
relationshipTo
in interfaceExposesRelationships<S extends NodeBase<?>>
- Parameters:
other
- The other end of the outgoing relationshiptypes
- The types to match- Returns:
- An ongoing relationship definition, that can be used to specify the type
-
relationshipFrom
public final RelationshipChain relationshipFrom(Node other, java.lang.String... types)
Description copied from interface:ExposesRelationships
Starts building an incoming relationship starting at theother
node
.- Specified by:
relationshipFrom
in interfaceExposesRelationships<S extends NodeBase<?>>
- Parameters:
other
- The source of the incoming relationshiptypes
- The types to match- Returns:
- An ongoing relationship definition, that can be used to specify the type
-
relationshipBetween
public final RelationshipChain relationshipBetween(Node other, java.lang.String... types)
Description copied from interface:ExposesRelationships
Starts building an undirected relationship between thisnode
and theother
.- Specified by:
relationshipBetween
in interfaceExposesRelationships<S extends NodeBase<?>>
- Parameters:
other
- The other end of the relationshiptypes
- The types to match- Returns:
- An ongoing relationship definition, that can be used to specify the type
-
asCondition
public final Condition asCondition()
Description copied from interface:RelationshipPattern
Transform this pattern into a condition. All names of the patterns must be known upfront in the final statement, as PatternExpressions are not allowed to introduce new variables.- Specified by:
asCondition
in interfaceRelationshipPattern
- Returns:
- A condition based on this pattern.
-
property
public final Property property(java.lang.String name)
Description copied from interface:PropertyContainer
Creates a newProperty
associated with this property container. This property can be used as a lookup in other expressions. It does not add a value to the property.Note: The property container does not track property creation and there is no possibility to enumerate all properties that have been created for this property container.
- Specified by:
property
in interfacePropertyContainer
- Parameters:
name
- property name, must not be null or empty.- Returns:
- a new
Property
associated with this named container
-
property
public final Property property(java.lang.String... names)
- Specified by:
property
in interfacePropertyContainer
-
property
public final Property property(Expression lookup)
Description copied from interface:PropertyContainer
Creates a newProperty
associated with this property container. This property can be used as a lookup in other expressions. It does not add a value to the property.The new
Property
object is a dynamic lookup, based on theexpression
passed to this method. The expression can be example another property, a function result or a Cypher parameter. A property defined in such a way will render asp[expression]
.Note: The property container does not track property creation and there is no possibility to enumerate all properties that have been created for this property container.
- Specified by:
property
in interfacePropertyContainer
- Parameters:
lookup
- the expression that is evaluated to lookup this property.- Returns:
- a new
Property
associated with this named container
-
mutate
public final Operation mutate(Parameter parameter)
Description copied from interface:PropertyContainer
Creates anOperation
mutating the properties of this container to a new value. The container does not track the operations created with this method.- Specified by:
mutate
in interfacePropertyContainer
- Parameters:
parameter
- the new properties- Returns:
- A new operation.
-
mutate
public final Operation mutate(MapExpression properties)
Description copied from interface:PropertyContainer
Creates anOperation
mutating the properties of this container to a new value. The container does not track the operations created with this method.- Specified by:
mutate
in interfacePropertyContainer
- Parameters:
properties
- the new properties- Returns:
- A new operation.
-
project
public final MapProjection project(java.util.List<java.lang.Object> entries)
Description copied from interface:PropertyContainer
Unwraps the list of entries into an array before creating a projection out of it.- Specified by:
project
in interfacePropertyContainer
- Parameters:
entries
- A list of entries for the projection- Returns:
- A map projection.
- See Also:
SymbolicName.project(List)
-
project
public final MapProjection project(java.lang.Object... entries)
Description copied from interface:PropertyContainer
Creates a map projection based on this container. The container needs a symbolic name for this to work.- Specified by:
project
in interfacePropertyContainer
- Parameters:
entries
- A list of entries for the projection- Returns:
- A map projection.
- See Also:
SymbolicName.project(Object...)
-
-