org.apache.cassandra.db.marshal

## Class AbstractType<T>

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

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

Direct Known Subclasses:
  AbstractCommutativeType, AbstractCompositeType, AsciiType, BooleanType, BytesType, CollectionType, ColumnToCollectionType, DateType, DecimalType, DoubleType, EmptyType, FloatType, InetAddressType, Int32Type, IntegerType, LexicalUUIDType, LocalByPartionerType, LongType, ReversedType, TimestampType, TimeUUIDType, UTF8Type, UUIDType

    public abstract class AbstractType<T>
    extends java.lang.Object
    implements java.util.Comparator<java.nio.ByteBuffer>

Specifies a Comparator for a specific type of ByteBuffer. Note that empty ByteBuffer are used to represent "start at the beginning" or "stop at the end" arguments to get_slice, so the Comparator should always handle those values even if they normally do not represent a valid ByteBuffer for the type being compared.

### Field Summary

Fields
`java.util.Comparator<Column>` `columnComparator`
`java.util.Comparator<Column>` `columnReverseComparator`
`java.util.Comparator<IndexHelper.IndexInfo>` `indexComparator`
`java.util.Comparator<IndexHelper.IndexInfo>` `indexReverseComparator`
`java.util.Comparator<OnDiskAtom>` `onDiskAtomComparator`
`java.util.Comparator<java.nio.ByteBuffer>` `reverseComparator`

### Constructor Summary

Constructors
`protected` `AbstractType()`

### Method Summary

Methods
`CQL3Type` `asCQL3Type()`
`int` `compareCollectionMembers(java.nio.ByteBuffer v1, java.nio.ByteBuffer v2, java.nio.ByteBuffer collectionName)` An alternative comparison function used by CollectionsType in conjunction with CompositeType.
`int` `componentsCount()` The number of subcomponents this type has.
`T` `compose(java.nio.ByteBuffer bytes)`
`java.nio.ByteBuffer` `decompose(T value)`
`abstract java.nio.ByteBuffer` `fromString(java.lang.String source)` get a byte representation of the given string.
`java.nio.ByteBuffer` `fromStringCQL2(java.lang.String source)` for compatibility with TimeUUID in CQL2.
`java.lang.String` `getColumnsString(java.lang.Iterable<Column> columns)`
`java.util.List<AbstractType<?>>` `getComponents()` Return a list of the "subcomponents" this type has.
`java.util.Comparator<java.nio.ByteBuffer>` `getReverseComparator()` Deprecated. use reverseComparator field instead
`abstract TypeSerializer<T>` `getSerializer()`
`java.lang.String` `getString(java.nio.ByteBuffer bytes)` get a string representation of the bytes suitable for log messages
`java.lang.String` `getString(java.util.Collection<java.nio.ByteBuffer> names)`
`protected boolean` `intersects(java.nio.ByteBuffer minColName, java.nio.ByteBuffer maxColName, java.nio.ByteBuffer sliceStart, java.nio.ByteBuffer sliceEnd)`
`boolean` `intersects(java.util.List<java.nio.ByteBuffer> minColumnNames, java.util.List<java.nio.ByteBuffer> maxColumnNames, SliceQueryFilter filter)`
`boolean` `isCollection()`
`boolean` `isCommutative()`
`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.
`boolean` `isValueCompatibleWith(AbstractType<?> previous)` Returns true if values of the previous AbstracType can be read by the this AbsractType.
`static AbstractType<?>` `parseDefaultParameters(AbstractType<?> baseType, TypeParser parser)`
`java.lang.String` `toString()` This must be overriden by subclasses if necessary so that for any AbstractType, this == TypeParser.parse(toString()).
`void` `validate(java.nio.ByteBuffer bytes)`
`void` `validateCollectionMember(java.nio.ByteBuffer bytes, java.nio.ByteBuffer collectionName)` An alternative validation function used by CollectionsType in conjunction with CompositeType.

### 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, equals`

### Field Detail

#### indexComparator

    public final java.util.Comparator<IndexHelper.IndexInfo> indexComparator

#### indexReverseComparator

    public final java.util.Comparator<IndexHelper.IndexInfo> indexReverseComparator

#### columnComparator

    public final java.util.Comparator<Column> columnComparator

#### columnReverseComparator

    public final java.util.Comparator<Column> columnReverseComparator

#### onDiskAtomComparator

    public final java.util.Comparator<OnDiskAtom> onDiskAtomComparator

#### reverseComparator

    public final java.util.Comparator<java.nio.ByteBuffer> reverseComparator

### Constructor Detail

#### AbstractType

    protected AbstractType()

### Method Detail

#### compose

    public T compose(java.nio.ByteBuffer bytes)

#### decompose

    public java.nio.ByteBuffer decompose(T value)

#### getString

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

get a string representation of the bytes suitable for log messages

#### fromString

    public abstract java.nio.ByteBuffer fromString(java.lang.String source)
                                            throws MarshalException

get a byte representation of the given string.

Throws:
  `MarshalException`

#### fromStringCQL2

    public java.nio.ByteBuffer fromStringCQL2(java.lang.String source)
                                       throws MarshalException

for compatibility with TimeUUID in CQL2. See TimeUUIDType (that overrides it).

Throws:
  `MarshalException`

#### validate

    public void validate(java.nio.ByteBuffer bytes)
                  throws MarshalException

Throws:
  `MarshalException`

#### asCQL3Type

    public CQL3Type asCQL3Type()

#### getSerializer

    public abstract TypeSerializer<T> getSerializer()

#### getReverseComparator

    public java.util.Comparator<java.nio.ByteBuffer> getReverseComparator()

Deprecated. use reverseComparator field instead

#### getString

    public java.lang.String getString(java.util.Collection<java.nio.ByteBuffer> names)

#### getColumnsString

    public java.lang.String getColumnsString(java.lang.Iterable<Column> columns)

#### isCommutative

    public boolean isCommutative()

#### parseDefaultParameters

    public static AbstractType<?> parseDefaultParameters(AbstractType<?> baseType,
                                         TypeParser parser)
                                                  throws SyntaxException

Throws:
  `SyntaxException`

#### isCompatibleWith

    public 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. 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!

#### isValueCompatibleWith

    public boolean isValueCompatibleWith(AbstractType<?> previous)

Returns true if values of the previous AbstracType can be read by the this AbsractType. Note that this is a weaker version of isCompatibleWith, as it does not require that both type compare values the same way. Note that a type should be compatible with at least itself.

#### compareCollectionMembers

    public int compareCollectionMembers(java.nio.ByteBuffer v1,
                               java.nio.ByteBuffer v2,
                               java.nio.ByteBuffer collectionName)

An alternative comparison function used by CollectionsType in conjunction with CompositeType. This comparator is only called to compare components of a CompositeType. It gets the value of the previous component as argument (or null if it's the first component of the composite). Unless you're doing something very similar to CollectionsType, you shouldn't override this.

#### validateCollectionMember

    public void validateCollectionMember(java.nio.ByteBuffer bytes,
                                java.nio.ByteBuffer collectionName)
                                  throws MarshalException

An alternative validation function used by CollectionsType in conjunction with CompositeType. This is similar to the compare function above.

Throws:
  `MarshalException`

#### isCollection

    public boolean isCollection()

#### componentsCount

    public int componentsCount()

The number of subcomponents this type has. This is always 1, i.e. the type has only itself as "subcomponents", except for CompositeType.

#### getComponents

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

Return a list of the "subcomponents" this type has. This always return a singleton list with the type itself except for CompositeType.

#### toString

    public java.lang.String toString()

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 `java.lang.Object`

#### intersects

    protected boolean intersects(java.nio.ByteBuffer minColName,
                     java.nio.ByteBuffer maxColName,
                     java.nio.ByteBuffer sliceStart,
                     java.nio.ByteBuffer sliceEnd)

#### intersects

    public boolean intersects(java.util.List<java.nio.ByteBuffer> minColumnNames,
                     java.util.List<java.nio.ByteBuffer> maxColumnNames,
                     SliceQueryFilter filter)