java.lang.Object
java.lang.Enum<ComparisonOperator>
org.gcube.informationsystem.resourceregistry.queries.operators.ComparisonOperator
All Implemented Interfaces:
Serializable, Comparable<ComparisonOperator>, Constable

public enum ComparisonOperator extends Enum<ComparisonOperator>
Defines OrientDB comparison and collection operators used in JSON queries.
Author:
Luca Frosini (ISTI - CNR)
  • Enum Constant Details

  • Field Details

    • operatorKey

      protected final String operatorKey
      The unique query operator key string.
    • numberOfOperand

      protected final int numberOfOperand
      The number of operands accepted by this operator.
    • dbOperator

      protected final String dbOperator
      The underlying OrientDB database operator string.
    • allowed

      protected final org.gcube.informationsystem.types.PropertyTypeName.BaseTypeGroup allowed
      The allowed value type group for operands.
    • description

      protected final String description
      The human-readable description of the operator.
  • Method Details

    • values

      public static ComparisonOperator[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static ComparisonOperator valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getOperatorKey

      public String getOperatorKey()
      Returns the unique query operator key string.
      Returns:
      the operator key string
    • getNumberOfOperand

      public int getNumberOfOperand()
      Returns the number of operands of the generated condition, the left-hand property included: 1 for a unary presence check, 2 for a binary comparison, 3 for a range with two bounds.
      Returns:
      the number of operands
    • getDbOperator

      public String getDbOperator()
      Returns the underlying OrientDB database operator string.
      Returns:
      the OrientDB database operator string
    • getDescription

      public String getDescription()
      Returns the human-readable description of the operator.
      Returns:
      the description string
    • getOperators

      public static Set<String> getOperators()
      Returns the set of all registered operator keys.
      Returns:
      the set of operator keys
    • getOperator

      public static ComparisonOperator getOperator(String key)
      Resolves a ComparisonOperator by its key.
      Parameters:
      key - the operator key
      Returns:
      the resolved ComparisonOperator, or null
    • addCondition

      public StringBuffer addCondition(String... operands)
      Builds a SQL condition from raw string operands: the left-hand property key followed by the right-hand values, getNumberOfOperand() operands in total.
      Parameters:
      operands - the property key and the right-hand values
      Returns:
      a string buffer containing the formatted SQL condition
      Throws:
      IllegalArgumentException - if the number of operands does not match the operator
    • getValue

      public static String getValue(org.gcube.com.fasterxml.jackson.databind.JsonNode jsonNode)
      Formats and escapes a JSON node value as a SQL-safe literal.

      Array nodes are formatted as an OrientDB collection literal (e.g. ["a", "b"]), each element individually escaped. Scalar nodes are formatted as a single literal.

      Parameters:
      jsonNode - the JSON value node
      Returns:
      the escaped SQL literal string
    • addCondition

      public StringBuffer addCondition(org.gcube.com.fasterxml.jackson.databind.JsonNode jn, String fieldNamePrefix)
      Builds a SQL condition from a JSON query node (subclass hook).
      Parameters:
      jn - the JSON query node
      fieldNamePrefix - the parent field name prefix
      Returns:
      the formatted SQL condition