Class JsonArrayTranslator

java.lang.Object
org.eclipse.edc.sql.translation.JsonArrayTranslator
All Implemented Interfaces:
FieldTranslator

public class JsonArrayTranslator extends Object implements FieldTranslator
This is a specialized translator, that targets object properties that are JSON array, for example someObject.jsonArray, and a criterion of "jsonArray contains foobar".

This is necessary, because with a conventional JsonFieldTranslator we would get (jsonArray -> 'jsonArray')::jsonb ?? ?, because it always assumes one indirection from columnName to object name.

The JsonArrayTranslator explicitly ignores this indirection.
  • Field Details

    • columnName

      protected final String columnName
  • Constructor Details

    • JsonArrayTranslator

      public JsonArrayTranslator(String columnName)
  • Method Details

    • getLeftOperand

      public String getLeftOperand(List<org.eclipse.edc.util.reflection.PathItem> path, Class<?> rightOperandType)
      Description copied from interface: FieldTranslator
      Get left operand for a SQL query given the canonical path name and the type
      Specified by:
      getLeftOperand in interface FieldTranslator
      Parameters:
      path - the path.
      Returns:
      the left operand.
    • toWhereClause

      public WhereClause toWhereClause(List<org.eclipse.edc.util.reflection.PathItem> path, org.eclipse.edc.spi.query.Criterion criterion, SqlOperator operator)
      Description copied from interface: FieldTranslator
      Translate the Criterion into a WhereClause.
      Specified by:
      toWhereClause in interface FieldTranslator
      Parameters:
      path - the path.
      criterion - the criterion.
      operator - the sql operator.
      Returns:
      the WhereClause.