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:
Visitable,ExposesPatternLengthAccessors<Relationship>,ExposesProperties<Relationship>,ExposesRelationships<RelationshipChain>,IdentifiableElement,Named,PatternElement,PropertyContainer,Relationship,RelationshipPattern
@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 RelationshipThis 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 protectedRelationshipBase(SymbolicName symbolicName, java.lang.String type, Node start, Properties properties, Node end)protectedRelationshipBase(SymbolicName symbolicName, Node start, java.lang.String type, Properties properties, Node end, java.lang.String... additionalTypes)Always creates a relationship from start to end (left to right).protectedRelationshipBase(S start, java.lang.String type, E end, java.lang.String... additionalTypes)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 voidaccept(Visitor visitor)@NotNull ConditionasCondition()Transform this pattern into a condition.@NotNull Relationship.DetailsgetDetails()The details contains the types, properties and cardinality.@NotNull NodegetLeft()@NotNull SymbolicNamegetRequiredSymbolicName()@NotNull NodegetRight()@NotNull java.util.Optional<SymbolicName>getSymbolicName()@NotNull Relationshipinverse()Creates a new relationship, inverting the direction but keeping the semantics intact ((a) --> (b)becomes(b) <-- (a)).@NotNull Relationshiplength(java.lang.Integer minimum, java.lang.Integer maximum)Creates a new relationship pattern with a new length@NotNull Relationshipmax(java.lang.Integer maximum)Creates a new relationship pattern with a new maximum length@NotNull Relationshipmin(java.lang.Integer minimum)Creates a new relationship pattern with a new minimum length@NotNull Operationmutate(MapExpression properties)Creates anOperationmutating the properties of this container to a new value.@NotNull Operationmutate(Parameter<?> parameter)Creates anOperationmutating the properties of this container to a new value.SELFnamed(java.lang.String newSymbolicName)Creates a copy of this relationship with a new symbolic name.abstract SELFnamed(SymbolicName newSymbolicName)This method needs to be implemented to provide new, type safe instances of this relationship.@NotNull MapProjectionproject(java.lang.Object... entries)Creates a map projection based on this container.@NotNull MapProjectionproject(java.util.List<java.lang.Object> entries)Unwraps the list of entries into an array before creating a projection out of it.@NotNull Propertyproperty(@NotNull java.lang.String name)Creates a newPropertyassociated with this property container.@NotNull Propertyproperty(java.lang.String... names)@NotNull Propertyproperty(Expression lookup)Creates a newPropertyassociated with this property container.@NotNull RelationshipChainrelationshipBetween(Node other, java.lang.String... types)Starts building an undirected relationship between thisnodeand theother.@NotNull RelationshipChainrelationshipFrom(Node other, java.lang.String... types)Starts building an incoming relationship starting at theothernode.@NotNull RelationshipChainrelationshipTo(Node other, java.lang.String... types)Starts building an outgoing relationship to theothernode.@NotNull Relationshipunbounded()Creates a new relationship pattern with an unbound length minimum lengthSELFwithProperties(java.lang.Object... keysAndValues)Creates a a copy of this property container with additional properties.SELFwithProperties(java.util.Map<java.lang.String,java.lang.Object> newProperties)Creates a a copy of this property container with additional properties.abstract SELFwithProperties(MapExpression newProperties)This method needs to be implemented to provide new, type safe instances of this relationship.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.neo4j.cypherdsl.core.Named
asExpression
-
-
-
-
Constructor Detail
-
RelationshipBase
protected RelationshipBase(S start, java.lang.String type, E end, java.lang.String... additionalTypes)
Always creates a relationship from start to end (left to right).- Parameters:
start- start nodeend- end nodetype- type of the relationshipadditionalTypes- additional types to add to the relationship
-
RelationshipBase
protected RelationshipBase(SymbolicName symbolicName, Node start, java.lang.String type, Properties properties, Node end, java.lang.String... additionalTypes)
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
-
RelationshipBase
protected RelationshipBase(SymbolicName symbolicName, java.lang.String type, Node start, Properties properties, Node end)
-
-
Method Detail
-
named
@NotNull public final SELF named(java.lang.String newSymbolicName)
Description copied from interface:RelationshipCreates a copy of this relationship with a new symbolic name.- Specified by:
namedin interfaceRelationship- Specified by:
namedin interfaceRelationshipPattern- Parameters:
newSymbolicName- the new symbolic name.- Returns:
- The new relationship.
-
named
@NotNull public abstract SELF named(SymbolicName newSymbolicName)
This method needs to be implemented to provide new, type safe instances of this relationship.- Specified by:
namedin interfaceRelationship- Specified by:
namedin interfaceRelationshipPattern- Parameters:
newSymbolicName- the new symbolic name.- Returns:
- A new relationship
-
withProperties
@NotNull public final SELF withProperties(java.lang.Object... keysAndValues)
Description copied from interface:ExposesPropertiesCreates 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:
withPropertiesin interfaceExposesProperties<S extends NodeBase<?>>- Parameters:
keysAndValues- A list of key and values. Must be an even number, with alternatingStringandExpression.- Returns:
- The new property container.
-
withProperties
@NotNull public final SELF withProperties(java.util.Map<java.lang.String,java.lang.Object> newProperties)
Description copied from interface:ExposesPropertiesCreates a a copy of this property container with additional properties.- Specified by:
withPropertiesin interfaceExposesProperties<S extends NodeBase<?>>- Parameters:
newProperties- A map with the new properties- Returns:
- The new property container.
-
withProperties
@NotNull public abstract SELF withProperties(MapExpression newProperties)
This method needs to be implemented to provide new, type safe instances of this relationship.- Specified by:
withPropertiesin interfaceExposesProperties<S extends NodeBase<?>>- Parameters:
newProperties- the new properties (can be null to remove exiting properties).- Returns:
- A new relationship
-
getLeft
@NotNull public final @NotNull Node getLeft()
- Specified by:
getLeftin interfaceRelationship
-
getRight
@NotNull public final @NotNull Node getRight()
- Specified by:
getRightin interfaceRelationship
-
getDetails
@NotNull public final @NotNull Relationship.Details getDetails()
Description copied from interface:RelationshipThe details contains the types, properties and cardinality.- Specified by:
getDetailsin interfaceRelationship- Returns:
- A wrapper around the details of this relationship.
-
unbounded
@NotNull public final @NotNull Relationship unbounded()
Description copied from interface:ExposesPatternLengthAccessorsCreates a new relationship pattern with an unbound length minimum length- Specified by:
unboundedin interfaceExposesPatternLengthAccessors<S extends NodeBase<?>>- Returns:
- the new relationship
-
min
@NotNull public final @NotNull Relationship min(java.lang.Integer minimum)
Description copied from interface:ExposesPatternLengthAccessorsCreates a new relationship pattern with a new minimum length- Specified by:
minin interfaceExposesPatternLengthAccessors<S extends NodeBase<?>>- Parameters:
minimum- the new minimum- Returns:
- the new relationship
-
max
@NotNull public final @NotNull Relationship max(java.lang.Integer maximum)
Description copied from interface:ExposesPatternLengthAccessorsCreates a new relationship pattern with a new maximum length- Specified by:
maxin interfaceExposesPatternLengthAccessors<S extends NodeBase<?>>- Parameters:
maximum- the new maximum- Returns:
- the new relationship
-
length
@NotNull public final @NotNull Relationship length(java.lang.Integer minimum, java.lang.Integer maximum)
Description copied from interface:ExposesPatternLengthAccessorsCreates a new relationship pattern with a new length- Specified by:
lengthin interfaceExposesPatternLengthAccessors<S extends NodeBase<?>>- Parameters:
minimum- the new minimummaximum- the new maximum- Returns:
- the new relationship
-
inverse
@NotNull public final @NotNull Relationship inverse()
Description copied from interface:RelationshipCreates 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:
inversein interfaceRelationship- Returns:
- the new relationship
-
getSymbolicName
@NotNull public final @NotNull java.util.Optional<SymbolicName> getSymbolicName()
- Specified by:
getSymbolicNamein interfaceNamed- Returns:
- An optional symbolic name.
-
getRequiredSymbolicName
@NotNull public final @NotNull SymbolicName getRequiredSymbolicName()
- Specified by:
getRequiredSymbolicNamein interfaceNamed- Returns:
- A symbolic name
-
relationshipTo
@NotNull public final @NotNull RelationshipChain relationshipTo(Node other, java.lang.String... types)
Description copied from interface:ExposesRelationshipsStarts building an outgoing relationship to theothernode.- Specified by:
relationshipToin 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
@NotNull public final @NotNull RelationshipChain relationshipFrom(Node other, java.lang.String... types)
Description copied from interface:ExposesRelationshipsStarts building an incoming relationship starting at theothernode.- Specified by:
relationshipFromin 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
@NotNull public final @NotNull RelationshipChain relationshipBetween(Node other, java.lang.String... types)
Description copied from interface:ExposesRelationshipsStarts building an undirected relationship between thisnodeand theother.- Specified by:
relationshipBetweenin 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
@NotNull public final @NotNull Condition asCondition()
Description copied from interface:RelationshipPatternTransform 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:
asConditionin interfaceRelationshipPattern- Returns:
- A condition based on this pattern.
-
property
@NotNull public final @NotNull Property property(@NotNull @NotNull java.lang.String name)
Description copied from interface:PropertyContainerCreates a newPropertyassociated 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:
propertyin interfacePropertyContainer- Parameters:
name- property name, must not be null or empty.- Returns:
- a new
Propertyassociated with this named container
-
property
@NotNull public final @NotNull Property property(java.lang.String... names)
- Specified by:
propertyin interfacePropertyContainer- Parameters:
names- a list of nested property names- Returns:
- a new
Propertyassociated with this named container - See Also:
PropertyContainer.property(String)
-
property
@NotNull public final @NotNull Property property(Expression lookup)
Description copied from interface:PropertyContainerCreates a newPropertyassociated 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
Propertyobject is a dynamic lookup, based on theexpressionpassed 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:
propertyin interfacePropertyContainer- Parameters:
lookup- the expression that is evaluated to lookup this property.- Returns:
- a new
Propertyassociated with this named container
-
mutate
@NotNull public final @NotNull Operation mutate(Parameter<?> parameter)
Description copied from interface:PropertyContainerCreates anOperationmutating the properties of this container to a new value. The container does not track the operations created with this method.- Specified by:
mutatein interfacePropertyContainer- Parameters:
parameter- the new properties- Returns:
- A new operation.
-
mutate
@NotNull public final @NotNull Operation mutate(MapExpression properties)
Description copied from interface:PropertyContainerCreates anOperationmutating the properties of this container to a new value. The container does not track the operations created with this method.- Specified by:
mutatein interfacePropertyContainer- Parameters:
properties- the new properties- Returns:
- A new operation.
-
project
@NotNull public final @NotNull MapProjection project(java.util.List<java.lang.Object> entries)
Description copied from interface:PropertyContainerUnwraps the list of entries into an array before creating a projection out of it.- Specified by:
projectin interfacePropertyContainer- Parameters:
entries- A list of entries for the projection- Returns:
- A map projection.
- See Also:
SymbolicName.project(List)
-
project
@NotNull public final @NotNull MapProjection project(java.lang.Object... entries)
Description copied from interface:PropertyContainerCreates a map projection based on this container. The container needs a symbolic name for this to work.- Specified by:
projectin interfacePropertyContainer- Parameters:
entries- A list of entries for the projection- Returns:
- A map projection.
- See Also:
SymbolicName.project(Object...)
-
-