Interface Expression

All Superinterfaces:
PropertyAccessor, Visitable
All Known Subinterfaces:
Case, Case.CaseEnding, Case.GenericCase, Case.SimpleCase, Condition, Literal<T>, Property, SubqueryExpression
All Known Implementing Classes:
AliasedExpression, Asterisk, BooleanLiteral, CollectExpression, Comparison, ConstantCondition, CountExpression, ExistentialSubquery, FunctionInvocation, HasLabelCondition, KeyValueMapEntry, ListComprehension, ListExpression, ListLiteral, ListOperator, MapExpression, MapLiteral, MapProjection, NestedExpression, NullLiteral, NumberLiteral, Operation, Parameter, PatternComprehension, PropertyLookup, StringLiteral, SymbolicName, TemporalLiteral

@API(status=STABLE, since="1.0") public interface Expression extends Visitable, PropertyAccessor
An expression can be used in many places, i.e. in return statements, pattern elements etc.
Since:
1.0
Author:
Michael J. Simons, Aakash Sorathiya
  • Method Details

    • includesAll

      default Condition includesAll(Expression rhs)
      Creates a condition that checks whether this expression includes all elements of rhs.
      Parameters:
      rhs - the other collection to compare to, must evaluate into a list during runtime.
      Returns:
      a new condition
      Since:
      2022.7.0
    • includesAny

      default Condition includesAny(Expression rhs)
      Creates a condition that checks whether this expression includes any element of rhs.
      Parameters:
      rhs - the other collection to compare to, must evaluate into a list during runtime.
      Returns:
      a new condition
      Since:
      2022.7.0
    • as

      default AliasedExpression as(String alias)
      Creates an expression with an alias. This expression does not track which or how many aliases have been created.
      Parameters:
      alias - the alias to use
      Returns:
      an aliased expression.
    • size

      default Expression size()
      This creates a size(e) expression from this expression. The Cypher output will semantically only be valid when this refers to a list (see size(list)) or when the expression is a string (see size() applied to string).

      Any other expression will produce Cypher that is either deprecated in Neo4j ≥ 4.4 or not supported at all.

      Returns:
      the size of this expression (Either the number of items in a list or the number of characters in a string expression).
      Since:
      2022.1.0
    • hasSize

      default Condition hasSize(Expression expectedSize)
      Takes the size() expresssions and compares it for equality with the parameter expectedSize. The same restrictions as with size() apply.
      Parameters:
      expectedSize - the expected size
      Returns:
      a condition
      Since:
      2022.1.0
      See Also:
    • as

      default AliasedExpression as(SymbolicName alias)
      Reuse an existing symbolic name to alias this expression.
      Parameters:
      alias - a symbolic name
      Returns:
      an aliased expression.
      Since:
      2021.0.2
    • asCondition

      default Condition asCondition()
      Transform this expression into a condition.
      Returns:
      this expression as a condition. Will return the same instance if it is already a condition.
      Since:
      2021.2.2
    • isEqualTo

      default Condition isEqualTo(Expression rhs)
      Creates a lhs = rhs condition.
      Parameters:
      rhs - the right hand side of the condition
      Returns:
      a new condition
    • eq

      default Condition eq(Expression rhs)
      An alias for isEqualTo(Expression).
      Parameters:
      rhs - the right hand side of the condition
      Returns:
      a new condition
    • isNotEqualTo

      default Condition isNotEqualTo(Expression rhs)
      Creates a lhs <> rhs condition.
      Parameters:
      rhs - the right hand side of the condition
      Returns:
      a new condition
    • ne

      default Condition ne(Expression rhs)
      Parameters:
      rhs - the right hand side of the condition
      Returns:
      a new condition
    • lt

      default Condition lt(Expression rhs)
      Creates a lhs < rhs condition.
      Parameters:
      rhs - the right hand side of the condition
      Returns:
      a new condition
    • lte

      default Condition lte(Expression rhs)
      Creates a lhs <= rhs condition.
      Parameters:
      rhs - the right hand side of the condition
      Returns:
      a new condition
    • gt

      default Condition gt(Expression rhs)
      Creates a lhs > rhs condition.
      Parameters:
      rhs - the right hand side of the condition
      Returns:
      a new condition
    • gte

      default Condition gte(Expression rhs)
      Creates a lhs >= rhs condition.
      Parameters:
      rhs - the right hand side of the condition
      Returns:
      a new condition
    • isTrue

      default Condition isTrue()
      Creates a condition that checks whether this expression is true.
      Returns:
      a new condition
    • isFalse

      default Condition isFalse()
      Creates a condition that checks whether this expression is false.
      Returns:
      a new condition
    • matches

      default Condition matches(Expression expression)
      Creates a condition that checks whether this expression matches that expression.
      Parameters:
      expression - the expression to match against. Must evaluate into a string during runtime.
      Returns:
      a new condition.
    • matches

      default Condition matches(String pattern)
      Creates a condition that checks whether this expression matches the given pattern.
      Parameters:
      pattern - the pattern to match
      Returns:
      a new condition.
    • startsWith

      default Condition startsWith(Expression expression)
      Creates a condition that checks whether this expression starts with that expression.
      Parameters:
      expression - the expression to match against. Must evaluate into a string during runtime.
      Returns:
      a new condition.
    • contains

      default Condition contains(Expression expression)
      Creates a condition that checks whether this expression contains that expression.
      Parameters:
      expression - the expression to match against. Must evaluate into a string during runtime.
      Returns:
      a new condition.
    • endsWith

      default Condition endsWith(Expression expression)
      Creates a condition that checks whether this expression ends with that expression.
      Parameters:
      expression - the expression to match against. Must evaluate into a string during runtime.
      Returns:
      a new condition.
    • concat

      default Operation concat(Expression expression)
      Creates an expression concatenating two string or list expressions.
      Parameters:
      expression - the expression to concat to this expression.
      Returns:
      a new expression.
    • add

      default Operation add(Expression addend)
      Creates a + operation of this (the augend) and the addend.
      Parameters:
      addend - the addend
      Returns:
      a new operation.
      Since:
      1.0.1
    • subtract

      default Operation subtract(Expression subtrahend)
      Creates a - operation of this (the minuend) and the subtrahend.
      Parameters:
      subtrahend - the subtrahend
      Returns:
      a new operation.
      Since:
      1.0.1
    • multiply

      default Operation multiply(Expression multiplicand)
      Creates a * operation of this (the multiplier) and the multiplicand.
      Parameters:
      multiplicand - the multiplicand
      Returns:
      a new operation.
      Since:
      1.0.1
    • divide

      default Operation divide(Expression dividend)
      Creates a / operation of this (the divisor) and the dividend.
      Parameters:
      dividend - the dividend
      Returns:
      a new operation.
      Since:
      1.0.1
    • remainder

      default Operation remainder(Expression dividend)
      Returns the remainder of this value and the dividend.
      Parameters:
      dividend - the dividend
      Returns:
      a new operation.
    • pow

      default Operation pow(Expression n)
      Returns the power of n of this value.
      Parameters:
      n - power to raise this Expression to.
      Returns:
      a new operation.
    • isNull

      default Condition isNull()
      Creates a IS NULL operation for this expression. The expression does not track the condition created here.
      Returns:
      a condition based on this expression that evaluates to true when this expression is null.
    • isNotNull

      default Condition isNotNull()
      Creates a IS NOT NULL operation for this expression. The expression does not track the condition created here.
      Returns:
      a condition based on this expression that evaluates to true when this expression is not null.
    • in

      default Condition in(Expression haystack)
      Creates a IN operation for this expression and that expression. The expression does not track the condition created here.
      Parameters:
      haystack - the expression to search for this expression
      Returns:
      a new condition.
    • isEmpty

      default Condition isEmpty()
      Creates a condition that evaluates to true if this expression is empty.
      Returns:
      a new condition.
    • descending

      default SortItem descending()
      The property does not track the sort items created here.
      Returns:
      a sort item for this property in descending order
    • ascending

      default SortItem ascending()
      The property does not track the sort items created here.
      Returns:
      a sort item for this property in ascending order
    • sorted

      default SortItem sorted(SortItem.Direction direction)
      Creates a new sort item with the given direction.
      Parameters:
      direction - the direction to sort
      Returns:
      a new sort item.
      Since:
      2021.4.1
    • property

      default 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

      default Property property(Expression lookup)
      Creates a new Property 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 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 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 interface PropertyAccessor
      Parameters:
      lookup - the expression that is evaluated to lookup this property.
      Returns:
      a new Property associated with this named container
      Since:
      2024.1.0