Enum Class MatemathicsOperator

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

public enum MatemathicsOperator extends Enum<MatemathicsOperator>
Author:
Luca Frosini (ISTI - CNR) OrientDB supports the eval() function to execute complex operations. Example: SELECT eval( "amount * 120 / 100 - discount" ) as finalPrice from Order See https://www.orientdb.com/docs/3.0.x/sql/SQL-Where.html#mathematics-operators https://www.orientdb.com/docs/3.0.x/sql/SQL-Syntax.html#math-operators https://www.orientdb.com/docs/3.0.x/sql/SQL-Syntax.html#math-operators-precedence https://www.orientdb.com/docs/3.0.x/sql/SQL-Syntax.html#array-concatenation
  • Enum Constant Details

    • SUM

      public static final MatemathicsOperator SUM
      The mathematical sum operator (+).
    • MINUS

      public static final MatemathicsOperator MINUS
      The mathematical subtraction operator (-).
    • MULTIPLY

      public static final MatemathicsOperator MULTIPLY
      The mathematical multiplication operator (*).
    • DIVIDE

      public static final MatemathicsOperator DIVIDE
      The mathematical division operator (/).
    • MODULE

      public static final MatemathicsOperator MODULE
      The mathematical modulo operator (%).
    • BITWISE_RIGHT_SHIFT

      public static final MatemathicsOperator BITWISE_RIGHT_SHIFT
      The bitwise right shift operator (>>).
    • BITWISE_LEFT_SHIFT

      public static final MatemathicsOperator BITWISE_LEFT_SHIFT
      The bitwise left shift operator (<<).
    • BITWISE_AND

      public static final MatemathicsOperator BITWISE_AND
      The bitwise AND operator (&).
    • BITWISE_OR

      public static final MatemathicsOperator BITWISE_OR
      The bitwise OR operator (|).
    • BITWISE_XOR

      public static final MatemathicsOperator BITWISE_XOR
      The bitwise XOR operator (^).
    • ARRAY_CONCATENATION

      public static final MatemathicsOperator ARRAY_CONCATENATION
      The array concatenation operator (||).
  • Field Details

    • logger

      protected static org.slf4j.Logger logger
      The logger instance.
    • VALUES_KEY

      public static final String VALUES_KEY
      The JSON property key for values.
      See Also:
    • SEPARATOR_KEY

      public static final String SEPARATOR_KEY
      The JSON property key for separator.
      See Also:
    • AS_KEY

      public static final String AS_KEY
      The JSON property key for alias.
      See Also:
    • operatorKey

      protected final String operatorKey
      The internal operator key.
    • dbOperator

      protected final String dbOperator
      The database operator symbol.
    • description

      protected final String description
      The operator description.
  • Method Details

    • values

      public static MatemathicsOperator[] 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 MatemathicsOperator 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

      protected String getOperatorKey()
      Returns the internal operator key.
      Returns:
      the operator key string
    • getDbOperator

      protected String getDbOperator()
      Returns the database operator symbol.
      Returns:
      the database operator symbol string
    • getDescription

      public String getDescription()
      Returns the operator description.
      Returns:
      the operator description string
    • getOperators

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

      public static MatemathicsOperator getOperator(String key)
      Returns the matching MatemathicsOperator for the specified key.
      Parameters:
      key - the operator key
      Returns:
      the matching operator, or null if not found
    • getError

      protected String getError(String key, Class<?> clazz, boolean mandatory)
      Throws a bad request exception indicating a query validation error.
      Parameters:
      key - the field key
      clazz - the expected class type
      mandatory - true if the field is mandatory
      Returns:
      the error message string (unreachable as it always throws)
    • generateFieldToEmit

      public String generateFieldToEmit(org.gcube.com.fasterxml.jackson.databind.JsonNode jsonNode, String fieldPrefix) throws org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException
      Generates and returns the database SQL math expression representation of the JSON operator.
      Parameters:
      jsonNode - the JSON node defining the operator and its values
      fieldPrefix - the field name prefix to apply
      Returns:
      the generated SQL math expression string
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException - if a nested operator is not valid
    • generateFieldToEmit

      public String generateFieldToEmit(org.gcube.com.fasterxml.jackson.databind.JsonNode jsonNode, MatemathicsOperator.FieldReference fieldReference) throws org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException
      Generates and returns the database SQL math expression representation of the JSON operator.
      Parameters:
      jsonNode - the JSON node defining the operator and its values
      fieldReference - the resolver of the SQL operand of each named field
      Returns:
      the generated SQL math expression string
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException - if a field name or a nested operator is not valid
    • addFieldPrefix

      protected StringBuffer addFieldPrefix(StringBuffer sb, String fieldPrefix)
      Helper method to append the field name prefix to the SQL buffer.
      Parameters:
      sb - the SQL buffer
      fieldPrefix - the prefix to apply
      Returns:
      the updated SQL buffer
    • generateFieldToEmit

      protected StringBuffer generateFieldToEmit(org.gcube.com.fasterxml.jackson.databind.node.ArrayNode arrayNode, String fieldsSeparator, MatemathicsOperator.FieldReference fieldReference) throws org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException
      Helper method to generate SQL math expressions for array elements.
      Parameters:
      arrayNode - the array of elements to process
      fieldsSeparator - the separator to apply for string fields
      fieldReference - the resolver of the SQL operand of each named field
      Returns:
      the updated SQL buffer
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException - if a field name or a nested operator is not valid