public class TupleType extends DataType
A tuple type is a essentially a list of types.
DataType.CollectionType, DataType.CustomType, DataType.Name, DataType.NativeType
Modifier and Type | Method and Description |
---|---|
boolean |
contains(TupleType other)
Return
true if this tuple type contains the given tuple type,
and false otherwise. |
boolean |
equals(Object o) |
List<DataType> |
getComponentTypes()
The (immutable) list of types composing this tuple type.
|
int |
hashCode() |
boolean |
isFrozen()
Returns whether this data type is frozen.
|
TupleValue |
newValue()
Returns a new empty value for this tuple type.
|
TupleValue |
newValue(Object... values)
Returns a new value for this tuple type that uses the provided values
for the components.
|
static TupleType |
of(ProtocolVersion protocolVersion,
CodecRegistry codecRegistry,
DataType... types)
Creates a "disconnected" tuple type (you should prefer
cluster.getMetadata().newTupleType(...)
whenever possible). |
String |
toString() |
allPrimitiveTypes, ascii, bigint, blob, cboolean, cdouble, cfloat, cint, counter, custom, date, decimal, frozenList, frozenMap, frozenSet, getName, getTypeArguments, inet, isCollection, list, list, map, map, set, set, smallint, text, time, timestamp, timeuuid, tinyint, uuid, varchar, varint
public static TupleType of(ProtocolVersion protocolVersion, CodecRegistry codecRegistry, DataType... types)
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.
protocolVersion
- the protocol version to use.codecRegistry
- the codec registry to use.types
- the types for the tuple type.public List<DataType> getComponentTypes()
public TupleValue newValue()
null
) value for this
user type definition.public TupleValue newValue(Object... values)
The numbers of values passed to this method must correspond to the
number of components in this tuple type. The i
th parameter
value will then be assigned to the i
th component of the resulting
tuple value.
values
- the values to use for the component of the resulting
tuple.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.public boolean isFrozen()
DataType
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.
public boolean contains(TupleType other)
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
.
other
- the tuple type to compare against the current onetrue
if this tuple type contains the given tuple type,
and false
otherwise.Copyright © 2012–2015. All rights reserved.