org.apache.cassandra.cql3.restrictions

## Class TokenRestriction

- java.lang.Object
- - org.apache.cassandra.cql3.restrictions.TokenRestriction

All Implemented Interfaces:
  Restriction

Direct Known Subclasses:
  TokenRestriction.EQ, TokenRestriction.Slice

    public abstract class TokenRestriction
    extends java.lang.Object

`Restriction` using the token function.

### Nested Class Summary

Nested Classes
`static class` `TokenRestriction.EQ`
`static class` `TokenRestriction.Slice`

### Field Summary

Fields
`protected java.util.List<ColumnDefinition>` `columnDefs` The definition of the columns to which apply the token restriction.
`protected CType` `ctype` The composite type.

### Constructor Summary

Constructors
Constructor and Description
`TokenRestriction(CType ctype, java.util.List<ColumnDefinition> columnDefs)` Creates a new `TokenRestriction` that apply to the specified columns.

### Method Summary

All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
`void` `addIndexExpressionTo(java.util.List<IndexExpression> expressions, SecondaryIndexManager indexManager, QueryOptions options)` Adds to the specified list the `IndexExpression`s corresponding to this `Restriction`.
`CompositesBuilder` `appendBoundTo(CFMetaData cfm, CompositesBuilder builder, Bound bound, QueryOptions options)` Appends the values of the `Restriction` for the specified bound to the specified builder.
`CompositesBuilder` `appendTo(CFMetaData cfm, CompositesBuilder builder, QueryOptions options)` Appends the values of this `Restriction` to the specified builder.
`java.util.List<java.nio.ByteBuffer>` `bounds(CFMetaData cfm, Bound b, QueryOptions options)`
`java.util.List<Composite>` `boundsAsComposites(CFMetaData cfm, Bound bound, QueryOptions options)`
`protected abstract org.apache.cassandra.cql3.restrictions.PrimaryKeyRestrictions` `doMergeWith(TokenRestriction otherRestriction)` Merges this restriction with the specified `TokenRestriction`.
`java.util.List<ColumnDefinition>` `getColumnDefs()` Returns the column definitions in position order.
`protected java.lang.String` `getColumnNamesAsString()` Returns the column names as a comma separated `String`.
`ColumnDefinition` `getFirstColumn()` Returns the definition of the first column.
`java.lang.Iterable<Function>` `getFunctions()` Return an Iterable over all of the functions (both native and user-defined) used by any component of the restrictions
`ColumnDefinition` `getLastColumn()` Returns the definition of the last column.
`boolean` `hasBound(Bound b)` Checks if the specified bound is set or not.
`boolean` `hasSupportingIndex(SecondaryIndexManager secondaryIndexManager)` Check if the restriction is on indexed columns.
`boolean` `isContains()`
`boolean` `isEmpty()` Checks if this `PrimaryKeyRestrictionSet` is empty or not.
`boolean` `isEQ()`
`boolean` `isIN()`
`boolean` `isInclusive(Bound b)` Checks if the specified bound is inclusive or not.
`boolean` `isMultiColumn()`
`boolean` `isNotReturningAnyRows(CFMetaData cfm, QueryOptions options)` Checks if this restriction will prevent the query to return any rows.
`boolean` `isOnToken()`
`boolean` `isSlice()`
`org.apache.cassandra.cql3.restrictions.PrimaryKeyRestrictions` `mergeWith(Restriction otherRestriction)` Merges this restriction with the specified one.
`protected static Bound` `reverseBoundIfNeeded(ColumnDefinition columnDefinition, Bound bound)` Reverses the specified bound if the column type is a reversed one.
`int` `size()` Returns the number of columns that have a restriction.
`protected static java.nio.ByteBuffer` `validateIndexedValue(ColumnSpecification columnSpec, java.nio.ByteBuffer value)`
`java.util.List<java.nio.ByteBuffer>` `values(CFMetaData cfm, QueryOptions options)`
`java.util.List<Composite>` `valuesAsComposites(CFMetaData cfm, QueryOptions options)`

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

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

### Methods inherited from interface org.apache.cassandra.cql3.restrictions.Restriction

`appendBoundTo, getFunctions, hasBound, isContains, isEQ, isIN, isInclusive, isMultiColumn, isNotReturningAnyRows, isSlice`

### Field Detail

#### columnDefs

    protected final java.util.List<ColumnDefinition> columnDefs

The definition of the columns to which apply the token restriction.

#### ctype

    protected final CType ctype

The composite type.

### Constructor Detail

#### TokenRestriction

    public TokenRestriction(CType ctype,
                            java.util.List<ColumnDefinition> columnDefs)

Creates a new `TokenRestriction` that apply to the specified columns.

Parameters:
  `ctype` - the composite type
  `columnDefs` - the definition of the columns to which apply the token restriction

### Method Detail

#### isOnToken

    public boolean isOnToken()

Specified by:
  `isOnToken` in interface `Restriction`

#### getColumnDefs

    public java.util.List<ColumnDefinition> getColumnDefs()

Description copied from interface: `Restriction`
Returns the column definitions in position order.

Returns:
  the column definitions in position order.

#### getFirstColumn

    public ColumnDefinition getFirstColumn()

Description copied from interface: `Restriction`
Returns the definition of the first column.

Returns:
  the definition of the first column.

#### getLastColumn

    public ColumnDefinition getLastColumn()

Description copied from interface: `Restriction`
Returns the definition of the last column.

Returns:
  the definition of the last column.

#### hasSupportingIndex

    public boolean hasSupportingIndex(SecondaryIndexManager secondaryIndexManager)

Description copied from interface: `Restriction`
Check if the restriction is on indexed columns.

Parameters:
  `secondaryIndexManager` - the index manager
Returns:
  `true` if the restriction is on indexed columns, `false`

#### addIndexExpressionTo

    public final void addIndexExpressionTo(java.util.List<IndexExpression> expressions,
                                           SecondaryIndexManager indexManager,
                                           QueryOptions options)

Description copied from interface: `Restriction`
Adds to the specified list the `IndexExpression`s corresponding to this `Restriction`.

Parameters:
  `expressions` - the list to add the `IndexExpression`s to
  `indexManager` - the secondary index manager
  `options` - the query options

#### appendTo

    public CompositesBuilder appendTo(CFMetaData cfm,
                                      CompositesBuilder builder,
                                      QueryOptions options)

Description copied from interface: `Restriction`
Appends the values of this `Restriction` to the specified builder.

Parameters:
  `cfm` - the table metadata
  `builder` - the `CompositesBuilder` to append to.
  `options` - the query options
Returns:
  the `CompositesBuilder`

#### valuesAsComposites

    public java.util.List<Composite> valuesAsComposites(CFMetaData cfm,
                                                        QueryOptions options)
                                                 throws InvalidRequestException

Throws:
  `InvalidRequestException`

#### boundsAsComposites

    public java.util.List<Composite> boundsAsComposites(CFMetaData cfm,
                                                        Bound bound,
                                                        QueryOptions options)
                                                 throws InvalidRequestException

Throws:
  `InvalidRequestException`

#### getColumnNamesAsString

    protected final java.lang.String getColumnNamesAsString()

Returns the column names as a comma separated `String`.

Returns:
  the column names as a comma separated `String`.

#### mergeWith

    public final org.apache.cassandra.cql3.restrictions.PrimaryKeyRestrictions mergeWith(Restriction otherRestriction)
                                                                                  throws InvalidRequestException

Description copied from interface: `Restriction`
Merges this restriction with the specified one.

Restriction are immutable. Therefore merging two restrictions result in a new one. The reason behind this choice is that it allow a great flexibility in the way the merging can done while preventing any side effect.

Parameters:
  `otherRestriction` - the restriction to merge into this one
Returns:
  the restriction resulting of the merge
Throws:
  `InvalidRequestException` - if the restrictions cannot be merged

#### doMergeWith

    protected abstract org.apache.cassandra.cql3.restrictions.PrimaryKeyRestrictions doMergeWith(TokenRestriction otherRestriction)
                                                                                          throws InvalidRequestException

Merges this restriction with the specified `TokenRestriction`.

Parameters:
  `otherRestriction` - the `TokenRestriction` to merge with.
Throws:
  `InvalidRequestException`

#### bounds

    public java.util.List<java.nio.ByteBuffer> bounds(CFMetaData cfm,
                                                      Bound b,
                                                      QueryOptions options)
                                               throws InvalidRequestException

Throws:
  `InvalidRequestException`

#### isEmpty

    public final boolean isEmpty()

Checks if this `PrimaryKeyRestrictionSet` is empty or not.

Returns:
  `true` if this `PrimaryKeyRestrictionSet` is empty, `false` otherwise.

#### size

    public final int size()

Returns the number of columns that have a restriction.

Returns:
  the number of columns that have a restriction.

#### values

    public java.util.List<java.nio.ByteBuffer> values(CFMetaData cfm,
                                                      QueryOptions options)
                                               throws InvalidRequestException

Throws:
  `InvalidRequestException`

#### getFunctions

    public java.lang.Iterable<Function> getFunctions()

Return an Iterable over all of the functions (both native and user-defined) used by any component of the restrictions

Returns:
  functions all functions found (may contain duplicates)

#### isMultiColumn

    public boolean isMultiColumn()

Specified by:
  `isMultiColumn` in interface `Restriction`

#### isSlice

    public boolean isSlice()

Specified by:
  `isSlice` in interface `Restriction`

#### isEQ

    public boolean isEQ()

Specified by:
  `isEQ` in interface `Restriction`

#### isIN

    public boolean isIN()

Specified by:
  `isIN` in interface `Restriction`

#### isContains

    public boolean isContains()

Specified by:
  `isContains` in interface `Restriction`

#### hasBound

    public boolean hasBound(Bound b)

Description copied from interface: `Restriction`
Checks if the specified bound is set or not.

Specified by:
  `hasBound` in interface `Restriction`
Parameters:
  `b` - the bound type
Returns:
  `true` if the specified bound is set, `false` otherwise

#### appendBoundTo

    public CompositesBuilder appendBoundTo(CFMetaData cfm,
                                           CompositesBuilder builder,
                                           Bound bound,
                                           QueryOptions options)

Description copied from interface: `Restriction`
Appends the values of the `Restriction` for the specified bound to the specified builder.

Specified by:
  `appendBoundTo` in interface `Restriction`
Parameters:
  `cfm` - the table metadata
  `builder` - the `CompositesBuilder` to append to.
  `bound` - the bound
  `options` - the query options
Returns:
  the `CompositesBuilder`

#### isInclusive

    public boolean isInclusive(Bound b)

Description copied from interface: `Restriction`
Checks if the specified bound is inclusive or not.

Specified by:
  `isInclusive` in interface `Restriction`
Parameters:
  `b` - the bound type
Returns:
  `true` if the specified bound is inclusive, `false` otherwise

#### isNotReturningAnyRows

    public boolean isNotReturningAnyRows(CFMetaData cfm,
                                         QueryOptions options)

Description copied from interface: `Restriction`
Checks if this restriction will prevent the query to return any rows.

Specified by:
  `isNotReturningAnyRows` in interface `Restriction`
Parameters:
  `cfm` - the table metadata
  `options` - the query options
Returns:
  `true` if this restriction will prevent the query to return any rows, otherwise

#### validateIndexedValue

    protected static java.nio.ByteBuffer validateIndexedValue(ColumnSpecification columnSpec,
                                                              java.nio.ByteBuffer value)
                                                       throws InvalidRequestException

Throws:
  `InvalidRequestException`

#### reverseBoundIfNeeded

    protected static Bound reverseBoundIfNeeded(ColumnDefinition columnDefinition,
                                                Bound bound)

Reverses the specified bound if the column type is a reversed one.

Parameters:
  `columnDefinition` - the column definition
  `bound` - the bound
Returns:
  the bound reversed if the column type was a reversed one or the original bound