Class CollectionBeanDefinition<T>
java.lang.Object
com.datastax.astra.internal.reflection.CollectionBeanDefinition<T>
- Type Parameters:
T- the type of the collection document entity being introspected
Provides introspection and metadata for a collection document entity.
This class inspects a JavaBean of type T annotated with DataApiCollection
to extract and manage metadata about its properties, particularly the document ID field
marked with DocumentId.
-
Constructor Summary
ConstructorsConstructorDescriptionCollectionBeanDefinition(Class<T> clazz) Constructor for the collection record definition. -
Method Summary
Modifier and TypeMethodDescriptionBuilds a CollectionDefinition from the @DataApiCollection annotation properties.booleancanSetId()Checks if the ID field can be written through a setter.Gets the ID value from the given instance.Gets the name of the ID field.getLexical(T instance) Gets the lexical value from the given instance.Gets the name of the lexical field.Gets the vector value from the given instance.Gets the name of the vector field.getVectorize(T instance) Gets the vectorize value from the given instance.Gets the name of the vectorize field.booleanChecks if this collection record has a field annotated with @DocumentId.booleanChecks if this collection record has a field annotated with @Lexical.booleanChecks if this collection record has a field annotated with @Vector.booleanChecks if this collection record has a field annotated with @Vectorize.voidSets the ID value on the given instance.
-
Constructor Details
-
CollectionBeanDefinition
Constructor for the collection record definition.- Parameters:
clazz- the class type
-
-
Method Details
-
getId
Gets the ID value from the given instance.- Parameters:
instance- the instance to extract the ID from- Returns:
- the ID value, or null if no @DocumentId field is defined or the value is null
- Throws:
IllegalStateException- if the ID field cannot be accessed
-
hasIdField
public boolean hasIdField()Checks if this collection record has a field annotated with @DocumentId.- Returns:
- true if an ID field exists, false otherwise
-
getIdFieldName
Gets the name of the ID field.- Returns:
- the ID field name, or null if no @DocumentId field is defined
-
canSetId
public boolean canSetId()Checks if the ID field can be written through a setter.- Returns:
- true if an ID field exists and a setter is available
-
setId
Sets the ID value on the given instance.- Parameters:
instance- the instance to updatevalue- the new ID value
-
getVectorize
Gets the vectorize value from the given instance.- Parameters:
instance- the instance to extract the vectorize value from- Returns:
- the vectorize value, or null if no @Vectorize field is defined or the value is null
- Throws:
IllegalStateException- if the vectorize field cannot be accessed
-
hasVectorizeField
public boolean hasVectorizeField()Checks if this collection record has a field annotated with @Vectorize.- Returns:
- true if a vectorize field exists, false otherwise
-
getVectorizeFieldName
Gets the name of the vectorize field.- Returns:
- the vectorize field name, or null if no @Vectorize field is defined
-
getLexical
Gets the lexical value from the given instance.- Parameters:
instance- the instance to extract the lexical value from- Returns:
- the lexical value, or null if no @Lexical field is defined or the value is null
- Throws:
IllegalStateException- if the lexical field cannot be accessed
-
hasLexicalField
public boolean hasLexicalField()Checks if this collection record has a field annotated with @Lexical.- Returns:
- true if a lexical field exists, false otherwise
-
getLexicalFieldName
Gets the name of the lexical field.- Returns:
- the lexical field name, or null if no @Lexical field is defined
-
getVector
Gets the vector value from the given instance.- Parameters:
instance- the instance to extract the vector value from- Returns:
- the vector value (float[] or DataAPIVector), or null if no @Vector field is defined or the value is null
- Throws:
IllegalStateException- if the vector field cannot be accessed
-
hasVectorField
public boolean hasVectorField()Checks if this collection record has a field annotated with @Vector.- Returns:
- true if a vector field exists, false otherwise
-
getVectorFieldName
Gets the name of the vector field.- Returns:
- the vector field name, or null if no @Vector field is defined
-
buildCollectionDefinition
Builds a CollectionDefinition from the @DataApiCollection annotation properties.- Returns:
- a CollectionDefinition configured according to the annotation, or null if no annotation present
-