Interface Expression

All Superinterfaces:
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
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

      @NotNull @Contract(pure=true) default @NotNull 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

      @NotNull @Contract(pure=true) default @NotNull 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

      @NotNull @Contract(pure=true) default @NotNull 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

      @NotNull @Contract(pure=true) default @NotNull 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

      @NotNull @Contract(pure=true) default @NotNull 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

      @NotNull @Contract(pure=true) default @NotNull 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

      @NotNull @Contract(pure=true) default @NotNull 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

      @NotNull @Contract(pure=true) default @NotNull Condition isEqualTo(Expression rhs)
      Creates a lhs = rhs condition.
      Parameters:
      rhs - The right hand side of the condition
      Returns:
      A new condition
    • eq

      @NotNull @Contract(pure=true) default @NotNull Condition eq(Expression rhs)
      An alias for isEqualTo(Expression).
      Parameters:
      rhs - The right hand side of the condition
      Returns:
      A new condition
    • isNotEqualTo

      @NotNull @Contract(pure=true) default @NotNull Condition isNotEqualTo(Expression rhs)
      Creates a lhs <> rhs condition.
      Parameters:
      rhs - The right hand side of the condition
      Returns:
      A new condition
    • ne

      @NotNull @Contract(pure=true) default @NotNull Condition ne(Expression rhs)
      Parameters:
      rhs - The right hand side of the condition
      Returns:
      A new condition
    • lt

      @NotNull @Contract(pure=true) default @NotNull Condition lt(Expression rhs)
      Creates a lhs < rhs condition.
      Parameters:
      rhs - The right hand side of the condition
      Returns:
      A new condition
    • lte

      @NotNull @Contract(pure=true) default @NotNull Condition lte(Expression rhs)
      Creates a lhs <= rhs condition.
      Parameters:
      rhs - The right hand side of the condition
      Returns:
      A new condition
    • gt

      @NotNull @Contract(pure=true) default @NotNull Condition gt(Expression rhs)
      Creates a lhs > rhs condition.
      Parameters:
      rhs - The right hand side of the condition
      Returns:
      A new condition
    • gte

      @NotNull @Contract(pure=true) default @NotNull Condition gte(Expression rhs)
      Creates a lhs >= rhs condition.
      Parameters:
      rhs - The right hand side of the condition
      Returns:
      A new condition
    • isTrue

      @NotNull @Contract(pure=true) default @NotNull Condition isTrue()
      Creates a condition that checks whether this expression is true.
      Returns:
      A new condition
    • isFalse

      @NotNull @Contract(pure=true) default @NotNull Condition isFalse()
      Creates a condition that checks whether this expression is false.
      Returns:
      A new condition
    • matches

      @NotNull @Contract(pure=true) default @NotNull 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

      @NotNull @Contract(pure=true) default @NotNull 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

      @NotNull @Contract(pure=true) default @NotNull 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

      @NotNull @Contract(pure=true) default @NotNull 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

      @NotNull @Contract(pure=true) default @NotNull 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

      @NotNull @Contract(pure=true) default @NotNull 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

      @NotNull @Contract(pure=true) default @NotNull 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

      @NotNull @Contract(pure=true) default @NotNull 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

      @NotNull @Contract(pure=true) default @NotNull 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

      @NotNull @Contract(pure=true) default @NotNull 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

      @NotNull @Contract(pure=true) default @NotNull Operation remainder(Expression dividend)
      Returns the remainder of this value and the dividend.
      Parameters:
      dividend - The dividend
      Returns:
      A new operation.
    • pow

      @NotNull @Contract(pure=true) default @NotNull 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

      @NotNull @Contract(pure=true) default @NotNull 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

      @NotNull @Contract(pure=true) default @NotNull 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

      @NotNull @Contract(pure=true) default @NotNull 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

      @NotNull @Contract(pure=true) default @NotNull Condition isEmpty()
      Creates a condition that evaluates to true if this expression is empty.
      Returns:
      A new condition.
    • descending

      @NotNull @Contract(pure=true) default @NotNull SortItem descending()
      The property does not track the sort items created here.
      Returns:
      A sort item for this property in descending order
    • ascending

      @NotNull @Contract(pure=true) default @NotNull SortItem ascending()
      The property does not track the sort items created here.
      Returns:
      A sort item for this property in ascending order
    • sorted

      @NotNull @Contract(pure=true) default @NotNull 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

      @NotNull @Contract(pure=true) default @NotNull Property property(String... names)
      Assumes that this expressions refers to a container of some type allowing to reference properties from it. Note: The expression does not track property creation and there is no possibility to enumerate all properties that have been created for it.
      Parameters:
      names - At least one non empty name. If multiple names are specified, the expression creates a nested property like this.name1.name2.
      Returns:
      a new Property associated with this expression
      Since:
      2021.0.0