Class TupleType


  • public class TupleType
    extends DataType
    A tuple type.

    A tuple type is a essentially a list of types.

    • Method Detail

      • of

        public static TupleType of​(ProtocolVersion protocolVersion,
                                   CodecRegistry codecRegistry,
                                   DataType... types)
        Creates a "disconnected" tuple type (you should prefer Metadata#newTupleType(DataType...) cluster.getMetadata().newTupleType(...) whenever possible).

        This method is only exposed for situations where you don't have a Cluster instance available. If you create a type with this method and use it with a Cluster later, you won't be able to set tuple fields with custom codecs registered against the cluster, or you might get errors if the protocol versions don't match.

        Parameters:
        protocolVersion - the protocol version to use.
        codecRegistry - the codec registry to use.
        types - the types for the tuple type.
        Returns:
        the newly created tuple type.
      • newValue

        public TupleValue newValue()
        Returns a new empty value for this tuple type.
        Returns:
        an empty (with all component to null) value for this user type definition.
      • newValue

        public TupleValue newValue​(java.lang.Object... values)
        Returns a new value for this tuple type that uses the provided values for the components.

        The numbers of values passed to this method must correspond to the number of components in this tuple type. The ith parameter value will then be assigned to the ith component of the resulting tuple value.

        Parameters:
        values - the values to use for the component of the resulting tuple.
        Returns:
        a new tuple values based on the provided values.
        Throws:
        java.lang.IllegalArgumentException - if the number of values provided does not correspond to the number of components in this tuple type.
        InvalidTypeException - if any of the provided value is not of the correct type for the component.
      • isFrozen

        public boolean isFrozen()
        Description copied from class: DataType
        Returns whether this data type is frozen.

        This applies to User Defined Types, tuples and nested collections. Frozen types are serialized as a single value in Cassandra's storage engine, whereas non-frozen types are stored in a form that allows updates to individual subfields.

        Specified by:
        isFrozen in class DataType
        Returns:
        whether this data type is frozen.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • contains

        public boolean contains​(TupleType other)
        Return true if this tuple type contains the given tuple type, and false otherwise.

        A tuple type is said to contain another one if the latter has fewer components than the former, but all of them are of the same type. E.g. the type tuple<int, text> is contained by the type tuple<int, text, double>.

        A contained type can be seen as a "partial" view of a containing type, where the missing components are supposed to be null.

        Parameters:
        other - the tuple type to compare against the current one
        Returns:
        true if this tuple type contains the given tuple type, and false otherwise.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • asFunctionParameterString

        public java.lang.String asFunctionParameterString()
        Description copied from class: DataType
        Returns a String representation of this data type suitable for inclusion as a parameter type in a function or aggregate signature.

        In such places, the String representation might vary from the canonical one as returned by Object.toString(); e.g. the frozen keyword is not accepted.

        Overrides:
        asFunctionParameterString in class DataType
        Returns:
        a String representation of this data type suitable for inclusion as a parameter type in a function or aggregate signature.