Class ColumnDefinition<TYPE>
- All Implemented Interfaces:
LogOutputAppendable
Every column definition has a valid column name: each factory method throws
NameValidator.InvalidNameException (an IllegalArgumentException) if the name is not, as determined by
NameValidator.validateColumnName(String).
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionfinal voidcheckCastTo(Class<?> destDataType) Checks if objects of typedataTypecan be cast todestDataType(equivalent todestDataType.isAssignableFrom(dataType)).final voidcheckCastTo(Class<?> destDataType, @Nullable Class<?> destComponentType) Checks if objects of typedataTypecan be cast todestDataType(equivalent todestDataType.isAssignableFrom(dataType)) and checks that objects of typecomponentTypecan be cast todestComponentType(both component types must be present and cast-able, or both must benull; when both present, is equivalent todestComponentType.isAssignableFrom(componentType)).static <T> ColumnDefinition<T> Creates anormalcolumn definition with no component type, after checking that it is valid.static <T> ColumnDefinition<T> create(@NotNull String name, @NotNull Class<T> dataType, @Nullable Class<?> componentType, @NotNull ColumnDefinition.ColumnType columnType) Creates a column definition, after checking that it is valid: thatnameis a valid column name, thatdataTypeis a valid column data type, and thatcomponentTypeis valid fordataType.voiddescribeDifferences(@NotNull List<String> differences, @NotNull ColumnDefinition<?> other, @NotNull String lhs, @NotNull String rhs, @NotNull String prefix, boolean includeColumnType) Enumerate the differences between this ColumnDefinition, and another one.Describes the column definition with respect to the fields that are checked inisCompatible(ColumnDefinition).booleanstatic ColumnDefinition<?> from(ColumnHeader<?> header) Creates anormalcolumn definition from a qstColumnHeader.static <T> ColumnDefinition<T> fromGenericType(@NotNull String name, @NotNull Class<T> dataType) Creates anormalcolumn definition for an arbitrary data type, inferring the component type.static <T> ColumnDefinition<T> fromGenericType(@NotNull String name, @NotNull Class<T> dataType, @Nullable Class<?> componentType) Creates anormalcolumn definition for an arbitrary data type.static <T> ColumnDefinition<T> fromGenericType(@NotNull String name, @NotNull Class<T> dataType, @Nullable Class<?> componentType, @NotNull ColumnDefinition.ColumnType columnType) Creates a column definition for an arbitrary data type.@NotNull ColumnDefinition.ColumnType@Nullable Class<?> The component type: for array andVectordata types, the type of the elements.The data type: the type of the column's values.@NotNull StringgetName()The column name.booleanhasCompatibleDataType(@NotNull ColumnDefinition<?> other) Compares two ColumnDefinitions somewhat more permissively than equals, disregarding matters of name, storage and derivation.inthashCode()booleanisCompatible(@NotNull ColumnDefinition<?> other) Compares two ColumnDefinitions somewhat more permissively than equals, disregarding matters of storage and derivation.booleanisDirect()booleanstatic <T> ColumnDefinition<T> static ColumnDefinition<?> of(String name, GenericType<?> type) Creates anormalcolumn definition for a qstGenericType.static <T> ColumnDefinition<T> of(String name, GenericVectorType<T, ?> type) static <T> ColumnDefinition<T> of(String name, NativeArrayType<T, ?> type) Creates anormalcolumn definition for a qstNativeArrayType.static ColumnDefinition<?> of(String name, PrimitiveType<?> type) Creates anormalcolumn definition for a qstPrimitiveType.static <T> ColumnDefinition<T> of(String name, PrimitiveVectorType<T, ?> type) static ColumnDefinition<?> static ColumnDefinition<Boolean> static ColumnDefinition<Byte> Creates anormalbyte column definition, with data typebyte.static ColumnDefinition<Character> Creates anormalchar column definition, with data typechar.static ColumnDefinition<Double> Creates anormaldouble column definition, with data typedouble.static ColumnDefinition<Duration> ofDuration(@NotNull String name) static ColumnDefinition<Float> Creates anormalfloat column definition, with data typefloat.static ColumnDefinition<Integer> Creates anormalint column definition, with data typeint.static ColumnDefinition<LocalDate> ofLocalDate(@NotNull String name) static ColumnDefinition<LocalTime> ofLocalTime(@NotNull String name) static ColumnDefinition<Long> Creates anormallong column definition, with data typelong.static ColumnDefinition<Short> Creates anormalshort column definition, with data typeshort.static ColumnDefinition<String> static ColumnDefinition<Instant> static <T extends Vector<?>>
ColumnDefinition<T> static <T extends Vector<?>>
ColumnDefinition<T> toString()<Other> ColumnDefinition<Other> withDataType(@NotNull Class<Other> newDataType) <Other> ColumnDefinition<Other> withDataType(@NotNull Class<Other> newDataType, @Nullable Class<?> newComponentType)
-
Field Details
-
ZERO_LENGTH_COLUMN_DEFINITION_ARRAY
-
-
Method Details
-
ofBoolean
- Parameters:
name- the column name- Returns:
- the column definition
-
ofByte
Creates anormalbyte column definition, with data typebyte.- Parameters:
name- the column name- Returns:
- the column definition
-
ofChar
Creates anormalchar column definition, with data typechar.- Parameters:
name- the column name- Returns:
- the column definition
-
ofShort
Creates anormalshort column definition, with data typeshort.- Parameters:
name- the column name- Returns:
- the column definition
-
ofInt
Creates anormalint column definition, with data typeint.- Parameters:
name- the column name- Returns:
- the column definition
-
ofLong
Creates anormallong column definition, with data typelong.- Parameters:
name- the column name- Returns:
- the column definition
-
ofFloat
Creates anormalfloat column definition, with data typefloat.- Parameters:
name- the column name- Returns:
- the column definition
-
ofDouble
Creates anormaldouble column definition, with data typedouble.- Parameters:
name- the column name- Returns:
- the column definition
-
ofString
- Parameters:
name- the column name- Returns:
- the column definition
-
ofTime
- Parameters:
name- the column name- Returns:
- the column definition
-
ofLocalTime
- Parameters:
name- the column name- Returns:
- the column definition
-
ofLocalDate
- Parameters:
name- the column name- Returns:
- the column definition
-
ofDuration
- Parameters:
name- the column name- Returns:
- the column definition
-
of
Creates anormalcolumn definition for a qstType. The data type is:- for
primitive types, the primitive type, exceptBooleanforBooleanType; - for
boxed types, the same as for the corresponding primitive type; - for other
generic types, the type's class, with the array orVectorcomponent type as the component type forarray types. ACustomTypewhose class is aVectorimplementation (outsideio.deephaven.vector, which CustomType does not allow) gets an inferred component type, as byfromGenericType(String, Class).
- Parameters:
name- the column nametype- the type- Returns:
- the column definition
- Throws:
IllegalArgumentException- iftypeis aCustomTypeforvoidorVoid
- for
-
of
Creates anormalcolumn definition for a qstPrimitiveType. The data type is the primitive type, exceptBooleanforBooleanType.- Parameters:
name- the column nametype- the type- Returns:
- the column definition
-
of
Creates anormalcolumn definition for a qstGenericType. The data type is the same as for the corresponding primitive type forboxed types, and otherwise the type's class, with the array orVectorcomponent type as the component type forarray types. ACustomTypewhose class is aVectorimplementation gets an inferred component type, as byfromGenericType(String, Class).- Parameters:
name- the column nametype- the type- Returns:
- the column definition
- Throws:
IllegalArgumentException- iftypeis aCustomTypeforvoidorVoid
-
of
Creates anormalcolumn definition for a qstArrayType: a native array orVectortype. The data type is the type's class, and the component type is the type's component type.- Parameters:
name- the column nametype- the type- Returns:
- the column definition
-
of
Creates anormalcolumn definition for a qstPrimitiveVectorType, such asIntVector. The data type is the Vector type, and the component type is its primitive component type.- Parameters:
name- the column nametype- the type- Returns:
- the column definition
-
of
Creates anormalcolumn definition for a qstGenericVectorType, anObjectVectorof a generic type. The data type isObjectVector, and thecomponent typeis the class of the type's component type, which supplies the element type thatObjectVectoronly expresses through generics:ObjectVector<Number>has component typeNumber, making it the Vector equivalent ofNumber[].- Parameters:
name- the column nametype- the type- Returns:
- the column definition
-
of
Creates anormalcolumn definition for a qstNativeArrayType. The data type is the array type, and the component type is the class of its component type.- Parameters:
name- the column nametype- the type- Returns:
- the column definition
-
ofVector
public static <T extends Vector<?>> ColumnDefinition<T> ofVector(@NotNull @NotNull String name, @NotNull @NotNull Class<T> vectorType) Creates anormalVectorcolumn definition. The data type isvectorType, and thecomponent typeis its element type: the primitive type for primitive Vectors, such asintforIntVector(the Vector equivalent ofint[]); andObjectforObjectVector, making itObjectVector<Object>, the Vector equivalent ofObject[]. To give anObjectVectora more specific element type, useofVector(String, Class, Class).- Parameters:
name- the column namevectorType- the Vector type- Returns:
- the column definition
- Throws:
IllegalArgumentException- ifvectorTypeis not a recognized Vector type
-
ofVector
public static <T extends Vector<?>> ColumnDefinition<T> ofVector(@NotNull @NotNull String name, @NotNull @NotNull Class<T> vectorType, @Nullable @Nullable Class<?> componentType) Creates anormalVectorcolumn definition. The data type isvectorType, and thecomponent typeis its element type.ObjectVectorexpresses its element type only through generics, socomponentTypesupplies it:ofVector(name, ObjectVector.class, Number.class)describesObjectVector<Number>, the Vector equivalent ofNumber[]. Primitive Vectors fix their element type, so for themcomponentTypemust be that primitive type, such asintforIntVector.- Parameters:
name- the column namevectorType- the Vector typecomponentType- the element type: any reference type butVoidforObjectVector, or the primitive type for a primitive Vector; ornullfor the default, which isObjectforObjectVector- Returns:
- the column definition
- Throws:
IllegalArgumentException- ifvectorTypeis not a recognized Vector type, orcomponentTypeis not valid for it
-
fromGenericType
public static <T> ColumnDefinition<T> fromGenericType(@NotNull @NotNull String name, @NotNull @NotNull Class<T> dataType) Creates anormalcolumn definition for an arbitrary data type, inferring the component type. Equivalent tofromGenericType(name, dataType, null, ColumnType.Normal); seefromGenericType(String, Class, Class, ColumnType)for how the data and component types are determined.- Parameters:
name- the column namedataType- the data type- Returns:
- the column definition
- Throws:
IllegalArgumentException- ifdataTypeis not a valid column data type
-
fromGenericType
public static <T> ColumnDefinition<T> fromGenericType(@NotNull @NotNull String name, @NotNull @NotNull Class<T> dataType, @Nullable @Nullable Class<?> componentType) Creates anormalcolumn definition for an arbitrary data type. Equivalent tofromGenericType(name, dataType, componentType, ColumnType.Normal); seefromGenericType(String, Class, Class, ColumnType)for how the data and component types are determined.- Parameters:
name- the column namedataType- the data typecomponentType- the component type, for array andVectordata types; inferred whennull- Returns:
- the column definition
- Throws:
IllegalArgumentException- ifdataTypeis not a valid column data type, orcomponentTypeis not valid fordataType
-
fromGenericType
public static <T> ColumnDefinition<T> fromGenericType(@NotNull @NotNull String name, @NotNull @NotNull Class<T> dataType, @Nullable @Nullable Class<?> componentType, @NotNull @NotNull ColumnDefinition.ColumnType columnType) Creates a column definition for an arbitrary data type.Like column sources, column definitions use
Booleanfor boolean columns and the primitive type for other primitive columns, sodataTypeis normalized:booleanbecomesBoolean, and the other boxed primitive types become their primitive types. Other data types are used as is.For array and
Vectordata types, thecomponent typeis the element type. WhencomponentTypeisnull, it is inferred: the array's component type for array data types; the primitive type for primitive Vectors, such asintforIntVector; andObjectforObjectVector. SinceObjectVectorexpresses its element type only through generics, givecomponentTypeto describe, for example,ObjectVector<Number>, the Vector equivalent ofNumber[]. Other data types have no component type unless one is given.- Parameters:
name- the column namedataType- the data type; may not bevoidorVoid, nor an array ofVoidcomponentType- the element type for array andVectordata types: for arrays, the array's component type or a more specific one; forObjectVector, any reference type; for primitive Vectors, their primitive type. NevervoidorVoid, nor an array of them. Ornullto infer itcolumnType- the column type- Returns:
- the column definition
- Throws:
IllegalArgumentException- ifdataTypeis not a valid column data type, orcomponentTypeis not valid fordataType
-
from
Creates anormalcolumn definition from a qstColumnHeader. The name is the header's name, and the data type is determined from the header's type as byof(String, Type).- Parameters:
header- the column header- Returns:
- the column definition
- Throws:
IllegalArgumentException- if the header's type is aCustomTypeforvoidorVoid
-
create
public static <T> ColumnDefinition<T> create(@NotNull @NotNull String name, @NotNull @NotNull Class<T> dataType) Creates anormalcolumn definition with no component type, after checking that it is valid. This callscreate(String, Class, Class, ColumnType)with anullcomponent type, and so, as there, uses the values as provided without normalization or inference.- Parameters:
name- the column namedataType- the data type; array andVectordata types are invalid here, as they require a component type- Returns:
- the column definition
- Throws:
NameValidator.InvalidNameException- ifnameis not a valid column nameIllegalArgumentException- ifdataTypeis not valid
-
create
public static <T> ColumnDefinition<T> create(@NotNull @NotNull String name, @NotNull @NotNull Class<T> dataType, @Nullable @Nullable Class<?> componentType, @NotNull @NotNull ColumnDefinition.ColumnType columnType) Creates a column definition, after checking that it is valid: thatnameis a valid column name, thatdataTypeis a valid column data type, and thatcomponentTypeis valid fordataType.The values are used exactly as provided, without normalization or inference. Unlike
fromGenericType(String, Class, Class, ColumnType), this does not mapbooleanor the boxed primitive types to the types that columns use, and does not infer a missing component type: adataTypeofbooleanorIntegeris rejected rather than converted toBooleanorint, and an array orVectordata type with anullcomponentTypeis rejected rather than given one. Callers that want normalization or inference should usefromGenericType,of, or one of theofVectormethods.- Parameters:
name- the column namedataType- the data type, as column definitions represent it:Booleanrather thanboolean, and the primitive type rather than its boxed type for other primitives; nevervoidorVoidcomponentType- the component type; required for array andVectordata types, where it is validated against the data type as described atgetComponentType(); may benullfor other data typescolumnType- the column type- Returns:
- the column definition
- Throws:
NameValidator.InvalidNameException- ifnameis not a valid column nameIllegalArgumentException- ifdataTypeorcomponentTypeis not valid
-
getName
The column name. It is always a valid column name, as determined byNameValidator.validateColumnName(String).- Returns:
- the column name
-
getDataType
The data type: the type of the column's values.Like column sources, column definitions use
Booleanfor boolean columns, and the primitive type for other primitive columns (such asint, neverInteger). The data type is nevervoidorVoid. For array andVectordata types, the type of the elements is thecomponent type.- Returns:
- the data type
-
getComponentType
The component type: for array andVectordata types, the type of the elements.A native array type already carries its element type, so for an array data type the component type is the array's component type (
NumberforNumber[]), or a more specific type that all elements are known to have (Integerfor aNumber[]holding onlyIntegers). Primitive Vectors likewise fix their element type: the component type of anIntVectorcolumn isint, as forint[].ObjectVector, however, expresses its element type only through generics, so the component type supplies it: anObjectVectorcolumn with component typeNumberis anObjectVector<Number>, the Vector equivalent ofNumber[], not anObject[]-like column with a narrower component type.Other data types have no component type, unless one was given when creating the definition.
- Returns:
- the component type, or
nullif there is none
-
getColumnType
-
withPartitioning
-
withNormal
-
withDataType
-
withDataType
public <Other> ColumnDefinition<Other> withDataType(@NotNull @NotNull Class<Other> newDataType, @Nullable @Nullable Class<?> newComponentType) -
withName
-
isPartitioning
public boolean isPartitioning() -
isDirect
public boolean isDirect() -
isCompatible
Compares two ColumnDefinitions somewhat more permissively than equals, disregarding matters of storage and derivation. Checks for equality ofname,dataType, andcomponentType. As such, this method has an equivalence relation, ieA.isCompatible(B) == B.isCompatible(A).- Parameters:
other- The ColumnDefinition to compare to- Returns:
- Whether the ColumnDefinition defines a column whose name and data are compatible with this ColumnDefinition
-
hasCompatibleDataType
Compares two ColumnDefinitions somewhat more permissively than equals, disregarding matters of name, storage and derivation. Checks for equality ofdataType, andcomponentType. As such, this method has an equivalence relation, ieA.hasCompatibleDataType(B) == B.hasCompatibleDataType(A).- Parameters:
other- - The ColumnDefinition to compare to.- Returns:
- True if the ColumnDefinition defines a column whose data is compatible with this ColumnDefinition.
-
describeForCompatibility
Describes the column definition with respect to the fields that are checked inisCompatible(ColumnDefinition).- Returns:
- the description for compatibility
-
describeDifferences
public void describeDifferences(@NotNull @NotNull List<String> differences, @NotNull @NotNull ColumnDefinition<?> other, @NotNull @NotNull String lhs, @NotNull @NotNull String rhs, @NotNull @NotNull String prefix, boolean includeColumnType) Enumerate the differences between this ColumnDefinition, and another one. Lines will be of the form "lhs attribute 'value' does not match rhs attribute 'value'.- Parameters:
differences- an array to which differences can be addedother- the ColumnDefinition under comparisonlhs- what to call "this" definitionrhs- what to call the other definitionprefix- begin each difference with this stringincludeColumnType- whether to includecolumnTypecomparisons
-
checkCastTo
Checks if objects of typedataTypecan be cast todestDataType(equivalent todestDataType.isAssignableFrom(dataType)). If not, this throws aClassCastException.- Parameters:
destDataType- the destination data type
-
checkCastTo
public final void checkCastTo(Class<?> destDataType, @Nullable @Nullable Class<?> destComponentType) Checks if objects of typedataTypecan be cast todestDataType(equivalent todestDataType.isAssignableFrom(dataType)) and checks that objects of typecomponentTypecan be cast todestComponentType(both component types must be present and cast-able, or both must benull; when both present, is equivalent todestComponentType.isAssignableFrom(componentType)). If not, this throws aClassCastException.- Parameters:
destDataType- the destination data typedestComponentType- the destination component type, may benull
-
equals
-
hashCode
public int hashCode() -
toString
-
append
- Specified by:
appendin interfaceLogOutputAppendable
-