org.apache.cassandra.cql3

## Class Relation

- java.lang.Object
- - org.apache.cassandra.cql3.Relation

- Direct Known Subclasses:
    MultiColumnRelation, SingleColumnRelation, TokenRelation

      public abstract class Relation
      extends java.lang.Object

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Operator` | `relationType`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Relation()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `isContains()` Checks if the operator of this relation is a `CONTAINS`.
    `boolean` | `isContainsKey()` Checks if the operator of this relation is a `CONTAINS_KEY`.
    `boolean` | `isEQ()` Checks if the operator of this relation is a `EQ`.
    `boolean` | `isIN()` Checks if the operator of this relation is a `IN`.
    `boolean` | `isMultiColumn()` Checks if this relation apply to multiple columns.
    `boolean` | `isSlice()` Checks if the operator of this relation is a `Slice` (GT, GTE, LTE, LT).
    `protected abstract Restriction` | `newContainsRestriction(CFMetaData cfm, VariableSpecifications boundNames, boolean isKey)` Creates a new Contains restriction instance.
    `protected abstract Restriction` | `newEQRestriction(CFMetaData cfm, VariableSpecifications boundNames)` Creates a new EQ restriction instance.
    `protected abstract Restriction` | `newINRestriction(CFMetaData cfm, VariableSpecifications boundNames)` Creates a new IN restriction instance.
    `protected abstract Restriction` | `newSliceRestriction(CFMetaData cfm, VariableSpecifications boundNames, Bound bound, boolean inclusive)` Creates a new Slice restriction instance.
    `boolean` | `onToken()` Checks if this relation is a token relation (e.g.
    `Operator` | `operator()`
    `protected ColumnDefinition` | `toColumnDefinition(CFMetaData cfm, ColumnIdentifier.Raw entity)` Converts the specified entity into a column definition.
    `Restriction` | `toRestriction(CFMetaData cfm, VariableSpecifications boundNames)` Converts this `Relation` into a `Restriction`.
    `protected abstract Term` | `toTerm(java.util.List<? extends ColumnSpecification> receivers, Term.Raw raw, java.lang.String keyspace, VariableSpecifications boundNames)` Converts the specified `Raw` into a `Term`.
    `protected java.util.List<Term>` | `toTerms(java.util.List<? extends ColumnSpecification> receivers, java.util.List<? extends Term.Raw> raws, java.lang.String keyspace, VariableSpecifications boundNames)` Converts the specified `Raw` terms into a `Term`s.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### relationType

          protected Operator relationType

  - ### Constructor Detail

    - #### Relation

          public Relation()

  - ### Method Detail

    - #### operator

          public Operator operator()

    - #### isMultiColumn

          public boolean isMultiColumn()

      Checks if this relation apply to multiple columns.
      Returns:
        `true` if this relation apply to multiple columns, `false` otherwise.

    - #### onToken

          public boolean onToken()

      Checks if this relation is a token relation (e.g.

          token(a) = token(1)

      ).
      Returns:
        `true` if this relation is a token relation, `false` otherwise.

    - #### isContains

          public final boolean isContains()

      Checks if the operator of this relation is a `CONTAINS`.
      Returns:
        `true` if the operator of this relation is a `CONTAINS`, `false` otherwise.

    - #### isContainsKey

          public final boolean isContainsKey()

      Checks if the operator of this relation is a `CONTAINS_KEY`.
      Returns:
        `true` if the operator of this relation is a `CONTAINS_KEY`, `false` otherwise.

    - #### isIN

          public final boolean isIN()

      Checks if the operator of this relation is a `IN`.
      Returns:
        `true` if the operator of this relation is a `IN`, `false` otherwise.

    - #### isEQ

          public final boolean isEQ()

      Checks if the operator of this relation is a `EQ`.
      Returns:
        `true` if the operator of this relation is a `EQ`, `false` otherwise.

    - #### isSlice

          public final boolean isSlice()

      Checks if the operator of this relation is a `Slice` (GT, GTE, LTE, LT).
      Returns:
        `true` if the operator of this relation is a `Slice`, `false` otherwise.

    - #### toRestriction

          public final Restriction toRestriction(CFMetaData cfm,
                                                 VariableSpecifications boundNames)
                                          throws InvalidRequestException

      Converts this `Relation` into a `Restriction`.
      Parameters:
        `cfm` - the Column Family meta data
        `boundNames` - the variables specification where to collect the bind variables
      Returns:
        the `Restriction` corresponding to this `Relation`
      Throws:
        `InvalidRequestException` - if this `Relation` is not valid

    - #### newEQRestriction

          protected abstract Restriction newEQRestriction(CFMetaData cfm,
                                                          VariableSpecifications boundNames)
                                                   throws InvalidRequestException

      Creates a new EQ restriction instance.
      Parameters:
        `cfm` - the Column Family meta data
        `boundNames` - the variables specification where to collect the bind variables
      Returns:
        a new EQ restriction instance.
      Throws:
        `InvalidRequestException` - if the relation cannot be converted into an EQ restriction.

    - #### newINRestriction

          protected abstract Restriction newINRestriction(CFMetaData cfm,
                                                          VariableSpecifications boundNames)
                                                   throws InvalidRequestException

      Creates a new IN restriction instance.
      Parameters:
        `cfm` - the Column Family meta data
        `boundNames` - the variables specification where to collect the bind variables
      Returns:
        a new IN restriction instance
      Throws:
        `InvalidRequestException` - if the relation cannot be converted into an IN restriction.

    - #### newSliceRestriction

          protected abstract Restriction newSliceRestriction(CFMetaData cfm,
                                                             VariableSpecifications boundNames,
                                                             Bound bound,
                                                             boolean inclusive)
                                                      throws InvalidRequestException

      Creates a new Slice restriction instance.
      Parameters:
        `cfm` - the Column Family meta data
        `boundNames` - the variables specification where to collect the bind variables
        `bound` - the slice bound
        `inclusive` - `true` if the bound is included.
      Returns:
        a new slice restriction instance
      Throws:
        `InvalidRequestException` - if the `Relation` is not valid

    - #### newContainsRestriction

          protected abstract Restriction newContainsRestriction(CFMetaData cfm,
                                                                VariableSpecifications boundNames,
                                                                boolean isKey)
                                                         throws InvalidRequestException

      Creates a new Contains restriction instance.
      Parameters:
        `cfm` - the Column Family meta data
        `boundNames` - the variables specification where to collect the bind variables
        `isKey` - `true` if the restriction to create is a CONTAINS KEY
      Returns:
        a new Contains `Restriction` instance
      Throws:
        `InvalidRequestException` - if the `Relation` is not valid

    - #### toTerm

          protected abstract Term toTerm(java.util.List<? extends ColumnSpecification> receivers,
                                         Term.Raw raw,
                                         java.lang.String keyspace,
                                         VariableSpecifications boundNames)
                                  throws InvalidRequestException

      Converts the specified `Raw` into a `Term`.
      Parameters:
        `receivers` - the columns to which the values must be associated at
        `raw` - the raw term to convert
        `keyspace` - the keyspace name
        `boundNames` - the variables specification where to collect the bind variables
      Returns:
        the `Term` corresponding to the specified `Raw`
      Throws:
        `InvalidRequestException` - if the `Raw` term is not valid

    - #### toTerms

          protected final java.util.List<Term> toTerms(java.util.List<? extends ColumnSpecification> receivers,
                                                       java.util.List<? extends Term.Raw> raws,
                                                       java.lang.String keyspace,
                                                       VariableSpecifications boundNames)
                                                throws InvalidRequestException

      Converts the specified `Raw` terms into a `Term`s.
      Parameters:
        `receivers` - the columns to which the values must be associated at
        `raws` - the raw terms to convert
        `keyspace` - the keyspace name
        `boundNames` - the variables specification where to collect the bind variables
      Returns:
        the `Term`s corresponding to the specified `Raw` terms
      Throws:
        `InvalidRequestException` - if the `Raw` terms are not valid

    - #### toColumnDefinition

          protected final ColumnDefinition toColumnDefinition(CFMetaData cfm,
                                                              ColumnIdentifier.Raw entity)
                                                       throws InvalidRequestException

      Converts the specified entity into a column definition.
      Parameters:
        `cfm` - the column family meta data
        `entity` - the entity to convert
      Returns:
        the column definition corresponding to the specified entity
      Throws:
        `InvalidRequestException` - if the entity cannot be recognized

Copyright © 2018 The Apache Software Foundation