public class UserType extends DataType implements Iterable<UserType.Field>
A UDT is a essentially a named collection of fields (with a name and a type).
Modifier and Type | Class and Description |
---|---|
static class |
UserType.Field
A UDT field.
|
DataType.CollectionType, DataType.CustomType, DataType.Name, DataType.NativeType
Modifier and Type | Method and Description |
---|---|
String |
asCQLQuery()
Returns a CQL query representing this user type.
|
String |
asFunctionParameterString()
Returns a String representation of this data type suitable for inclusion as a parameter type in
a function or aggregate signature.
|
boolean |
contains(String name)
Returns whether this UDT contains a given field.
|
UserType |
copy(boolean newFrozen) |
boolean |
equals(Object o) |
String |
exportAsString()
Returns a CQL query representing this user type in human readable form.
|
Collection<String> |
getFieldNames()
Returns the names of the fields of this UDT.
|
DataType |
getFieldType(String name)
Returns the type of a given field.
|
String |
getKeyspace()
The name of the keyspace this UDT is part of.
|
String |
getTypeName()
The name of this user type.
|
int |
hashCode() |
boolean |
isFrozen()
Returns whether this data type is frozen.
|
Iterator<UserType.Field> |
iterator()
Returns an iterator over the fields of this UDT.
|
UDTValue |
newValue()
Returns a new empty value for this user type definition.
|
int |
size()
Returns the number of fields in this UDT.
|
String |
toString() |
allPrimitiveTypes, ascii, bigint, blob, cboolean, cdouble, cfloat, cint, counter, custom, date, decimal, duration, frozenList, frozenMap, frozenSet, getName, getTypeArguments, inet, isCollection, list, list, map, map, set, set, smallint, text, time, timestamp, timeuuid, tinyint, uuid, varchar, varint
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
forEach, spliterator
public UDTValue newValue()
public String getKeyspace()
public String getTypeName()
public int size()
public boolean contains(String name)
name
- the name to check. Note that name
obey the usual CQL identifier rules: it
should be quoted if it denotes a case sensitive identifier (you can use Metadata.quote(java.lang.String)
for the quoting).true
if this UDT contains a field named name
, false
otherwise.public Iterator<UserType.Field> iterator()
iterator
in interface Iterable<UserType.Field>
public Collection<String> getFieldNames()
public DataType getFieldType(String name)
name
- the name of the field. Note that name
obey the usual CQL identifier rules:
it should be quoted if it denotes a case sensitive identifier (you can use Metadata.quote(java.lang.String)
for the quoting).name
if this UDT has a field of this name, null
otherwise.IllegalArgumentException
- if name
is not a field of this UDT definition.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 UserType copy(boolean newFrozen)
public String exportAsString()
This method is equivalent to asCQLQuery()
but the ouptut is formatted to be human
readable (for some definition of human readable).
public String asCQLQuery()
This method returns a single 'CREATE TYPE' query corresponding to this UDT definition.
Note that the returned string is a single line; the returned query is not formatted in any way.
exportAsString()
public String asFunctionParameterString()
DataType
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.
asFunctionParameterString
in class DataType
Copyright © 2012–2024. All rights reserved.