UserType (apache-cassandra API)
Date: 2018-02-14

org.apache.cassandra.db.marshal

## Class UserType

- java.lang.Object
- - org.apache.cassandra.db.marshal.AbstractType<java.nio.ByteBuffer>
  - - org.apache.cassandra.db.marshal.TupleType
    - - org.apache.cassandra.db.marshal.UserType

- All Implemented Interfaces:
    java.util.Comparator<java.nio.ByteBuffer>, AssignmentTestable

      public class UserType
      extends TupleType

  A user defined type. A user type is really just a tuple type on steroids.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.apache.cassandra.db.marshal.AbstractType

      `AbstractType.ComparisonType`

    - ### Nested classes/interfaces inherited from interface org.apache.cassandra.cql3.AssignmentTestable

      `AssignmentTestable.TestResult`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `java.lang.String` | `keyspace`
    `java.nio.ByteBuffer` | `name`

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

      `types`

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

      `comparisonType, isByteOrderComparable, reverseComparator`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `UserType(java.lang.String keyspace, java.nio.ByteBuffer name, java.util.List<FieldIdentifier> fieldNames, java.util.List<AbstractType<?>> fieldTypes, boolean isMultiCell)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `CQL3Type` | `asCQL3Type()`
    `CellPath` | `cellPathForField(FieldIdentifier fieldName)`
    `boolean` | `equals(java.lang.Object o)`
    `boolean` | `equals(java.lang.Object o, boolean ignoreFreezing)` Checks to see if two types are equal when ignoring or not ignoring differences in being frozen, depending on the value of the ignoreFreezing parameter.
    `FieldIdentifier` | `fieldName(int i)`
    `java.lang.String` | `fieldNameAsString(int i)`
    `java.util.List<FieldIdentifier>` | `fieldNames()`
    `int` | `fieldPosition(FieldIdentifier fieldName)`
    `AbstractType<?>` | `fieldType(int i)`
    `java.util.List<AbstractType<?>>` | `fieldTypes()`
    `UserType` | `freeze()`
    `AbstractType<?>` | `freezeNestedMulticellTypes()` Returns an AbstractType instance that is equivalent to this one, but with all nested UDTs and collections explicitly frozen.
    `Term` | `fromJSONObject(java.lang.Object parsed)` Given a parsed JSON string, return a byte representation of the object.
    `static UserType` | `getInstance(TypeParser parser)`
    `java.lang.String` | `getNameAsString()`
    `TypeSerializer<java.nio.ByteBuffer>` | `getSerializer()`
    `int` | `hashCode()`
    `boolean` | `isFreezable()`
    `boolean` | `isMultiCell()`
    `boolean` | `isTuple()`
    `boolean` | `isUDT()`
    `boolean` | `isValueCompatibleWith(AbstractType<?> previous)` Returns true if values of the other AbstractType can be read and "reasonably" interpreted by the this AbstractType.
    `ShortType` | `nameComparator()`
    `boolean` | `referencesDuration()`
    `boolean` | `referencesUserType(java.lang.String userTypeName)`
    `java.nio.ByteBuffer` | `serializeForNativeProtocol(java.util.Iterator<Cell> cells, ProtocolVersion protocolVersion)`
    `java.lang.String` | `toJSONString(java.nio.ByteBuffer buffer, ProtocolVersion protocolVersion)` Converts the specified value into its JSON representation.
    `java.lang.String` | `toString()` This must be overriden by subclasses if necessary so that for any AbstractType, this == TypeParser.parse(toString()).
    `java.lang.String` | `toString(boolean ignoreFreezing)`
    `void` | `validateCell(Cell cell)`

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

      `allTypes, buildValue, compareCustom, fromString, getString, isCompatibleWith, isValueCompatibleWithInternal, size, split, type`

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

      `asCQLTypeStringList, checkComparable, compare, compareCollectionMembers, compareForCQL, componentsCount, compose, decompose, getComponents, getString, isCollection, isCounter, isEmptyValueMeaningless, isFrozenCollection, isReversed, parseDefaultParameters, readValue, readValue, skipValue, testAssignment, validate, validateCellValue, validateCollectionMember, valueLengthIfFixed, writeValue, writtenLength`

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

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

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

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

- - ### Field Detail

    - #### keyspace

          public final java.lang.String keyspace

    - #### name

          public final java.nio.ByteBuffer name

  - ### Constructor Detail

    - #### UserType

          public UserType(java.lang.String keyspace,
                          java.nio.ByteBuffer name,
                          java.util.List<FieldIdentifier> fieldNames,
                          java.util.List<AbstractType<?>> fieldTypes,
                          boolean isMultiCell)

  - ### Method Detail

    - #### getInstance

          public static UserType getInstance(TypeParser parser)
                                      throws ConfigurationException,
                                             SyntaxException

      Throws:
        `ConfigurationException`
        `SyntaxException`

    - #### isUDT

          public boolean isUDT()

      Overrides:
        `isUDT` in class `AbstractType<java.nio.ByteBuffer>`

    - #### isMultiCell

          public boolean isMultiCell()

      Overrides:
        `isMultiCell` in class `AbstractType<java.nio.ByteBuffer>`

    - #### isFreezable

          public boolean isFreezable()

      Overrides:
        `isFreezable` in class `AbstractType<java.nio.ByteBuffer>`

    - #### fieldType

          public AbstractType<?> fieldType(int i)

    - #### fieldTypes

          public java.util.List<AbstractType<?>> fieldTypes()

    - #### fieldName

          public FieldIdentifier fieldName(int i)

    - #### fieldNameAsString

          public java.lang.String fieldNameAsString(int i)

    - #### fieldNames

          public java.util.List<FieldIdentifier> fieldNames()

    - #### getNameAsString

          public java.lang.String getNameAsString()

    - #### fieldPosition

          public int fieldPosition(FieldIdentifier fieldName)

    - #### cellPathForField

          public CellPath cellPathForField(FieldIdentifier fieldName)

    - #### nameComparator

          public ShortType nameComparator()

    - #### serializeForNativeProtocol

          public java.nio.ByteBuffer serializeForNativeProtocol(java.util.Iterator<Cell> cells,
                                                                ProtocolVersion protocolVersion)

    - #### validateCell

          public void validateCell(Cell cell)
                            throws MarshalException

      Throws:
        `MarshalException`

    - #### fromJSONObject

          public Term fromJSONObject(java.lang.Object parsed)
                              throws MarshalException

      Description copied from class: `AbstractType`
      Given a parsed JSON string, return a byte representation of the object.
      Overrides:
        `fromJSONObject` in class `TupleType`
      Parameters:
        `parsed` - the result of parsing a json string
      Throws:
        `MarshalException`

    - #### toJSONString

          public java.lang.String toJSONString(java.nio.ByteBuffer buffer,
                                               ProtocolVersion protocolVersion)

      Description copied from class: `AbstractType`
      Converts the specified value into its JSON representation.

      The buffer position will stay the same.

      Overrides:
        `toJSONString` in class `TupleType`
      Parameters:
        `buffer` - the value to convert
        `protocolVersion` - the protocol version to use for the conversion
      Returns:
        a JSON string representing the specified value

    - #### freeze

          public UserType freeze()

      Overrides:
        `freeze` in class `AbstractType<java.nio.ByteBuffer>`

    - #### freezeNestedMulticellTypes

          public AbstractType<?> freezeNestedMulticellTypes()

      Description copied from class: `AbstractType`
      Returns an AbstractType instance that is equivalent to this one, but with all nested UDTs and collections explicitly frozen. This is only necessary for `2.x -> 3.x` schema migrations, and can be removed in Cassandra 4.0. See CASSANDRA-11609 and CASSANDRA-11613.
      Overrides:
        `freezeNestedMulticellTypes` in class `AbstractType<java.nio.ByteBuffer>`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `TupleType`

    - #### isValueCompatibleWith

          public boolean isValueCompatibleWith(AbstractType<?> previous)

      Description copied from class: `AbstractType`
      Returns true if values of the other AbstractType can be read and "reasonably" interpreted by the this AbstractType. Note that this is a weaker version of isCompatibleWith, as it does not require that both type compare values the same way. The restriction on the other type being "reasonably" interpreted is to prevent, for example, IntegerType from being compatible with all other types. Even though any byte string is a valid IntegerType value, it doesn't necessarily make sense to interpret a UUID or a UTF8 string as an integer. Note that a type should be compatible with at least itself.
      Overrides:
        `isValueCompatibleWith` in class `AbstractType<java.nio.ByteBuffer>`

    - #### equals

          public boolean equals(java.lang.Object o)

      Specified by:
        `equals` in interface `java.util.Comparator<java.nio.ByteBuffer>`
      Overrides:
        `equals` in class `TupleType`

    - #### equals

          public boolean equals(java.lang.Object o,
                                boolean ignoreFreezing)

      Description copied from class: `AbstractType`
      Checks to see if two types are equal when ignoring or not ignoring differences in being frozen, depending on the value of the ignoreFreezing parameter.
      Overrides:
        `equals` in class `AbstractType<java.nio.ByteBuffer>`
      Parameters:
        `o` - type to compare
        `ignoreFreezing` - if true, differences in the types being frozen will be ignored

    - #### asCQL3Type

          public CQL3Type asCQL3Type()

      Overrides:
        `asCQL3Type` in class `TupleType`

    - #### referencesUserType

          public boolean referencesUserType(java.lang.String userTypeName)

      Overrides:
        `referencesUserType` in class `TupleType`

    - #### referencesDuration

          public boolean referencesDuration()

      Overrides:
        `referencesDuration` in class `TupleType`

    - #### 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 `TupleType`

    - #### isTuple

          public boolean isTuple()

      Overrides:
        `isTuple` in class `TupleType`

    - #### toString

          public java.lang.String toString(boolean ignoreFreezing)

      Overrides:
        `toString` in class `AbstractType<java.nio.ByteBuffer>`
      Parameters:
        `ignoreFreezing` - if true, the type string will not be wrapped with FrozenType(...), even if this type is frozen.

    - #### getSerializer

          public TypeSerializer<java.nio.ByteBuffer> getSerializer()

      Overrides:
        `getSerializer` in class `TupleType`

Copyright © 2018 The Apache Software Foundation