Class NodeBase<SELF extends Node>

java.lang.Object
org.neo4j.cypherdsl.core.NodeBase<SELF>
Type Parameters:
SELF - the type of this node
All Implemented Interfaces:
Visitable, ExposesProperties<Node>, ExposesRelationships<Relationship>, IdentifiableElement, Named, Node, PatternElement, PropertyAccessor, PropertyContainer

@API(status=STABLE, since="2021.1.0") public abstract class NodeBase<SELF extends Node> extends Object implements Node
This is the base class for all nodes. It can be used with generics, specifying a valid type. This is useful when using it as a base class for a static metamodel.
Since:
2021.1.0
Author:
Michael J. Simons
  • Constructor Details

    • NodeBase

      protected NodeBase(String primaryLabel, String... additionalLabels)
      Creates a new base object from a set of labels.
      Parameters:
      primaryLabel - the primary label
      additionalLabels - an optional list of additional ones.
    • NodeBase

      protected NodeBase(SymbolicName symbolicName, List<NodeLabel> staticLabels, Properties properties)
      Creates a new base object from a SymbolicName name, a list of labels and a set of properties.
      Parameters:
      symbolicName - the symbolic name for this node object
      staticLabels - the list of labels, no primary is given
      properties - a set of properties
  • Method Details

    • named

      public final SELF named(String newSymbolicName)
      Description copied from interface: Node
      Creates a copy of this node with a new symbolic name.
      Specified by:
      named in interface Node
      Parameters:
      newSymbolicName - the new symbolic name.
      Returns:
      the new node.
    • named

      public abstract SELF named(SymbolicName newSymbolicName)
      This method needs to be implemented to provide new, type safe instances of this node.
      Specified by:
      named in interface Node
      Parameters:
      newSymbolicName - the new symbolic name.
      Returns:
      a new node
    • withProperties

      public final SELF withProperties(Object... keysAndValues)
      Description copied from interface: ExposesProperties
      Creates 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 interface ExposesProperties<SELF extends Node>
      Parameters:
      keysAndValues - a list of key and values. Must be an even number, with alternating String and Expression.
      Returns:
      the new property container.
    • withProperties

      public final SELF withProperties(Map<String,Object> newProperties)
      A new object with a new set of properties.
      Specified by:
      withProperties in interface ExposesProperties<SELF extends Node>
      Parameters:
      newProperties - a map with the new properties
      Returns:
      a new object
    • withProperties

      public abstract SELF withProperties(MapExpression newProperties)
      This method needs to be implemented to provide new, type safe instances of this node.
      Specified by:
      withProperties in interface ExposesProperties<SELF extends Node>
      Parameters:
      newProperties - the new properties (can be null to remove exiting properties).
      Returns:
      a new node
    • getProperties

      protected final Properties getProperties()
      Returns set of properties for this node.
      Returns:
      set of properties for this node
    • getLabels

      public final List<NodeLabel> getLabels()
      Description copied from interface: Node
      Returns the labels associated with this Node.
      Specified by:
      getLabels in interface Node
      Returns:
      the labels associated with this Node
    • getSymbolicName

      public final Optional<SymbolicName> getSymbolicName()
      Description copied from interface: Named
      Returns an optional symbolic name.
      Specified by:
      getSymbolicName in interface Named
      Returns:
      an optional symbolic name
    • getRequiredSymbolicName

      public final SymbolicName getRequiredSymbolicName()
      Description copied from interface: Named
      Return a symbolic name.
      Specified by:
      getRequiredSymbolicName in interface Named
      Returns:
      a symbolic name
    • accept

      public final void accept(Visitor visitor)
      Description copied from interface: Visitable
      Accept a Visitor visiting this Visitable and its nested Visitables if applicable.
      Specified by:
      accept in interface Visitable
      Parameters:
      visitor - the visitor to notify, must not be null.
    • hasLabels

      @Deprecated(forRemoval=true) public final Condition hasLabels(LabelExpression labels)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: Node
      Returns a condition that checks for the presence of a label expression on a node.
      Specified by:
      hasLabels in interface Node
      Parameters:
      labels - the labels to check
      Returns:
      a condition that checks whether this node has all the labels to query
    • hasLabels

      public final Condition hasLabels(String... labelsToQuery)
      Description copied from interface: Node
      A condition that checks for the presence of labels on a node.
      Specified by:
      hasLabels in interface Node
      Parameters:
      labelsToQuery - a list of labels to query
      Returns:
      a condition that checks whether this node has all the labels to query
    • hasLabels

      public final Condition hasLabels(Labels labels)
      Description copied from interface: Node
      Returns a condition that checks for the presence of a label expression on a node.
      Specified by:
      hasLabels in interface Node
      Parameters:
      labels - the labels to check
      Returns:
      a condition that checks whether this node has all the labels to query
    • isEqualTo

      public final Condition isEqualTo(Node otherNode)
      Description copied from interface: Node
      Creates a new condition whether this node is equal to otherNode.
      Specified by:
      isEqualTo in interface Node
      Parameters:
      otherNode - the node to compare this node to.
      Returns:
      a condition.
    • isNotEqualTo

      public final Condition isNotEqualTo(Node otherNode)
      Description copied from interface: Node
      Creates a new condition whether this node is not equal to otherNode.
      Specified by:
      isNotEqualTo in interface Node
      Parameters:
      otherNode - the node to compare this node to.
      Returns:
      a condition.
    • isNull

      public final Condition isNull()
      Description copied from interface: Node
      Creates a new condition based on this node whether it is null.
      Specified by:
      isNull in interface Node
      Returns:
      a condition.
    • isNotNull

      public final Condition isNotNull()
      Description copied from interface: Node
      Creates a new condition based on this node whether it is not null.
      Specified by:
      isNotNull in interface Node
      Returns:
      a condition.
    • descending

      public final SortItem descending()
      Description copied from interface: Node
      Creates a new sort item of this node in descending order.
      Specified by:
      descending in interface Node
      Returns:
      a sort item.
    • ascending

      public final SortItem ascending()
      Description copied from interface: Node
      Creates a new sort item of this node in ascending order.
      Specified by:
      ascending in interface Node
      Returns:
      a sort item.
    • as

      public final AliasedExpression as(String alias)
      Description copied from interface: Node
      Creates an alias for this node.
      Specified by:
      as in interface Node
      Parameters:
      alias - the alias to use.
      Returns:
      the aliased expression.
    • internalId

      public final FunctionInvocation internalId()
      Description copied from interface: Node
      Returns a new function invocation returning the internal id of this node.
      Specified by:
      internalId in interface Node
      Returns:
      a new function invocation returning the internal id of this node
    • labels

      public final FunctionInvocation labels()
      Description copied from interface: Node
      Returns a new function invocation returning the labels of this node.
      Specified by:
      labels in interface Node
      Returns:
      a new function invocation returning the labels of this node
    • relationshipTo

      public final Relationship relationshipTo(Node other, String... types)
      Description copied from interface: ExposesRelationships
      Starts building an outgoing relationship to the other node.
      Specified by:
      relationshipTo in interface ExposesRelationships<Relationship>
      Parameters:
      other - the other end of the outgoing relationship
      types - the types to match
      Returns:
      an ongoing relationship definition, that can be used to specify the type
    • relationshipFrom

      public final Relationship relationshipFrom(Node other, String... types)
      Description copied from interface: ExposesRelationships
      Starts building an incoming relationship starting at the other node.
      Specified by:
      relationshipFrom in interface ExposesRelationships<Relationship>
      Parameters:
      other - the source of the incoming relationship
      types - the types to match
      Returns:
      an ongoing relationship definition, that can be used to specify the type
    • relationshipBetween

      public final Relationship relationshipBetween(Node other, String... types)
      Description copied from interface: ExposesRelationships
      Starts building an undirected relationship between this node and the other.
      Specified by:
      relationshipBetween in interface ExposesRelationships<Relationship>
      Parameters:
      other - the other end of the relationship
      types - the types to match
      Returns:
      an ongoing relationship definition, that can be used to specify the type
    • toString

      public String toString()
      Description copied from interface: Visitable
      Most visitables will render themselves into a Cypher fragment preceded with the actual classname. The representation however is not cached - in contrast to the ones for full statements. Using toString is recommended for debugging purposes mainly, and not for production use.

      The concrete classname has been prepended to help debugging and actually to discourage using fragments to build queries without explicitly rendering them, either as statement or going through the renderer on purpose.

      Specified by:
      toString in interface Visitable
      Overrides:
      toString in class Object
      Returns:
      a string representation of this visitable formatted as Classname{cypher=value}
    • property

      public final Property property(String name)
      Description copied from interface: PropertyAccessor
      Creates a new Property associated with this element. This property can be used as a lookup in other expressions. It does not add a value to the property.

      Note: The element 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 interface PropertyAccessor
      Parameters:
      name - property name, must not be null or empty.
      Returns:
      a new Property associated with this element
    • property

      public final Property property(String... names)
      Description copied from interface: PropertyAccessor
      Returns a new Property associated with this element.
      Specified by:
      property in interface PropertyAccessor
      Parameters:
      names - a list of nested property names
      Returns:
      a new Property associated with this element
      See Also:
    • property

      public final Property property(Expression lookup)
      Description copied from interface: PropertyAccessor
      Creates a new Property associated with this element. 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 the expression 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 as p[expression].

      Note: The element 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 interface PropertyAccessor
      Parameters:
      lookup - the expression that is evaluated to lookup this property.
      Returns:
      a new Property associated with this element
    • mutate

      public final Operation mutate(Parameter<?> parameter)
      Description copied from interface: PropertyContainer
      Creates an Operation 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 interface PropertyContainer
      Parameters:
      parameter - the new properties
      Returns:
      a new operation.
    • mutate

      public final Operation mutate(MapExpression properties)
      Description copied from interface: PropertyContainer
      Creates an Operation 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 interface PropertyContainer
      Parameters:
      properties - the new properties
      Returns:
      a new operation.
    • set

      public final Operation set(Parameter<?> parameter)
      Description copied from interface: PropertyContainer
      Creates an SET operation setting the properties of this container to a new value. The container does not track the operations created with this method.
      Specified by:
      set in interface PropertyContainer
      Parameters:
      parameter - the new properties
      Returns:
      a new operation.
    • set

      public final Operation set(MapExpression properties)
      Description copied from interface: PropertyContainer
      Creates an SET operation setting the properties of this container to a new value. The container does not track the operations created with this method.
      Specified by:
      set in interface PropertyContainer
      Parameters:
      properties - the new properties
      Returns:
      a new operation.
    • project

      public final MapProjection project(List<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 interface PropertyContainer
      Parameters:
      entries - a list of entries for the projection
      Returns:
      a map projection.
      See Also:
    • project

      public final MapProjection project(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 interface PropertyContainer
      Parameters:
      entries - a list of entries for the projection
      Returns:
      a map projection.
      See Also: