Class CollectionType<T>

  • All Implemented Interfaces:
    java.util.Comparator<java.nio.ByteBuffer>, AssignmentTestable
    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" (as a custom type for instance).
    • Method Detail

      • nameComparator

        public abstract AbstractType<?> nameComparator()
      • valueComparator

        public abstract AbstractType<?> valueComparator()
      • serializedValues

        protected abstract java.util.List<java.nio.ByteBuffer> serializedValues​(java.util.Iterator<Cell<?>> cells)
      • getString

        public <V> java.lang.String getString​(V value,
                                              ValueAccessor<V> accessor)
        Description copied from class: AbstractType
        get a string representation of the bytes used for various identifier (NOT just 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>
      • isMap

        public boolean isMap()
        Checks if this collection is Map.
        Returns:
        true if this collection is a Map, false otherwise.
      • collectionSize

        protected int collectionSize​(java.util.List<java.nio.ByteBuffer> values)
      • serializeForNativeProtocol

        public java.nio.ByteBuffer serializeForNativeProtocol​(java.util.Iterator<Cell<?>> cells,
                                                              ProtocolVersion 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
      • equals

        public boolean equals​(java.lang.Object o)
        Specified by:
        equals in interface java.util.Comparator<T>
        Overrides:
        equals in class java.lang.Object
      • 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>