CollectionType (apache-cassandra API)
Date: 2018-02-12

org.apache.cassandra.db.marshal

## Class CollectionType<T>

- java.lang.Object
- - org.apache.cassandra.db.marshal.AbstractType<T>
  - - org.apache.cassandra.db.marshal.CollectionType<T>

- All Implemented Interfaces:
    java.util.Comparator<java.nio.ByteBuffer>
  Direct Known Subclasses:
    ListType, MapType, SetType

      public abstract class CollectionType<T>
      extends AbstractType<T>

  The abstract validator that is the base for maps, sets and lists (both frozen and non-frozen). Please note that this comparator shouldn't be used "manually" (through thrift for instance).

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `CollectionType.Kind`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `CollectionType.Kind` | `kind`
    `static int` | `MAX_ELEMENTS`

    - ### Fields inherited from class org.apache.cassandra.db.marshal.AbstractType

      `reverseComparator`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `CollectionType(CollectionType.Kind kind)`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `CQL3Type` | `asCQL3Type()`
    `java.util.List<Cell>` | `enforceLimit(ColumnDefinition def, java.util.List<Cell> cells, int version)`
    `java.nio.ByteBuffer` | `fromString(java.lang.String source)` get a byte representation of the given string.
    `abstract CollectionSerializer<T>` | `getSerializer()`
    `java.lang.String` | `getString(java.nio.ByteBuffer bytes)` get a string representation of the bytes suitable for log messages
    `boolean` | `isCollection()`
    `boolean` | `isCompatibleWith(AbstractType<?> previous)` Returns true if this comparator is compatible with the provided previous comparator, that is if previous can safely be replaced by this.
    `protected abstract boolean` | `isCompatibleWithFrozen(CollectionType<?> previous)` A version of isCompatibleWith() to deal with non-multicell (frozen) collections
    `boolean` | `isMap()` Checks if this collection is Map.
    `protected abstract boolean` | `isValueCompatibleWithFrozen(CollectionType<?> previous)` A version of isValueCompatibleWith() to deal with non-multicell (frozen) collections
    `boolean` | `isValueCompatibleWithInternal(AbstractType<?> previous)` Needed to handle ReversedType in value-compatibility checks.
    `ColumnSpecification` | `makeCollectionReceiver(ColumnSpecification collection, boolean isKey)`
    `abstract AbstractType<?>` | `nameComparator()`
    `abstract java.util.List<java.nio.ByteBuffer>` | `serializedValues(java.util.List<Cell> cells)`
    `java.nio.ByteBuffer` | `serializeForNativeProtocol(ColumnDefinition def, java.util.List<Cell> cells, int version)`
    `java.lang.String` | `toString()` This must be overriden by subclasses if necessary so that for any AbstractType, this == TypeParser.parse(toString()).
    `void` | `validateCellValue(java.nio.ByteBuffer cellValue)` Validate cell value.
    `abstract AbstractType<?>` | `valueComparator()`

    - ### Methods inherited from class org.apache.cassandra.db.marshal.AbstractType

      `asCQLTypeStringList, compareCollectionMembers, componentsCount, compose, decompose, freeze, fromJSONObject, getComponents, getString, isByteOrderComparable, isCounter, isEmptyValueMeaningless, isFrozenCollection, isMultiCell, isReversed, isValueCompatibleWith, parseDefaultParameters, references, toJSONString, toString, validate, validateCollectionMember`

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

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

    - ### Methods inherited from interface java.util.Comparator

      `compare, comparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong`

- - ### Field Detail

    - #### MAX_ELEMENTS

          public static final int MAX_ELEMENTS

      See Also:
        Constant Field Values

    - #### kind

          public final CollectionType.Kind kind

  - ### Constructor Detail

    - #### CollectionType

          protected CollectionType(CollectionType.Kind kind)

  - ### Method Detail

    - #### nameComparator

          public abstract AbstractType<?> nameComparator()

    - #### valueComparator

          public abstract AbstractType<?> valueComparator()

    - #### getSerializer

          public abstract CollectionSerializer<T> getSerializer()

      Specified by:
        `getSerializer` in class `AbstractType<T>`

    - #### makeCollectionReceiver

          public ColumnSpecification makeCollectionReceiver(ColumnSpecification collection,
                                                            boolean isKey)

    - #### getString

          public java.lang.String getString(java.nio.ByteBuffer bytes)

      Description copied from class: `AbstractType`
      get a string representation of the bytes suitable for log messages
      Overrides:
        `getString` in class `AbstractType<T>`

    - #### fromString

          public java.nio.ByteBuffer fromString(java.lang.String source)

      Description copied from class: `AbstractType`
      get a byte representation of the given string.
      Specified by:
        `fromString` in class `AbstractType<T>`

    - #### isCollection

          public boolean isCollection()

      Overrides:
        `isCollection` in class `AbstractType<T>`

    - #### validateCellValue

          public void validateCellValue(java.nio.ByteBuffer cellValue)
                                 throws MarshalException

      Description copied from class: `AbstractType`
      Validate cell value. Unlike AbstractType.validate(java.nio.ByteBuffer), cell value is passed to validate its content. Usually, this is the same as validate except collection.
      Overrides:
        `validateCellValue` in class `AbstractType<T>`
      Parameters:
        `cellValue` - ByteBuffer representing cell value
      Throws:
        `MarshalException`

    - #### isMap

          public boolean isMap()

      Checks if this collection is Map.
      Returns:
        `true` if this collection is a Map, `false` otherwise.

    - #### enforceLimit

          public java.util.List<Cell> enforceLimit(ColumnDefinition def,
                                                   java.util.List<Cell> cells,
                                                   int version)

    - #### serializedValues

          public abstract java.util.List<java.nio.ByteBuffer> serializedValues(java.util.List<Cell> cells)

    - #### serializeForNativeProtocol

          public java.nio.ByteBuffer serializeForNativeProtocol(ColumnDefinition def,
                                                                java.util.List<Cell> cells,
                                                                int version)

    - #### isCompatibleWith

          public boolean isCompatibleWith(AbstractType<?> previous)

      Description copied from class: `AbstractType`
      Returns true if this comparator is compatible with the provided previous comparator, that is if previous can safely be replaced by this. A comparator cn should be compatible with a previous one cp if forall columns c1 and c2, if cn.validate(c1) and cn.validate(c2) and cn.compare(c1, c2) == v, then cp.validate(c1) and cp.validate(c2) and cp.compare(c1, c2) == v. Note that a type should be compatible with at least itself and when in doubt, keep the default behavior of not being compatible with any other comparator!
      Overrides:
        `isCompatibleWith` in class `AbstractType<T>`

    - #### isValueCompatibleWithInternal

          public boolean isValueCompatibleWithInternal(AbstractType<?> previous)

      Description copied from class: `AbstractType`
      Needed to handle ReversedType in value-compatibility checks. Subclasses should implement this instead of isValueCompatibleWith().
      Overrides:
        `isValueCompatibleWithInternal` in class `AbstractType<T>`

    - #### isCompatibleWithFrozen

          protected abstract boolean isCompatibleWithFrozen(CollectionType<?> previous)

      A version of isCompatibleWith() to deal with non-multicell (frozen) collections

    - #### isValueCompatibleWithFrozen

          protected abstract boolean isValueCompatibleWithFrozen(CollectionType<?> previous)

      A version of isValueCompatibleWith() to deal with non-multicell (frozen) collections

    - #### asCQL3Type

          public CQL3Type asCQL3Type()

      Overrides:
        `asCQL3Type` in class `AbstractType<T>`

    - #### toString

          public java.lang.String toString()

      Description copied from class: `AbstractType`
      This must be overriden by subclasses if necessary so that for any AbstractType, this == TypeParser.parse(toString()). Note that for backwards compatibility this includes the full classname. For CQL purposes the short name is fine.
      Overrides:
        `toString` in class `AbstractType<T>`

Copyright © 2018 The Apache Software Foundation