Class FieldDescriptor
java.lang.Object
nl.datasteel.crudcraft.codegen.descriptor.field.FieldDescriptor
Represents a field in a model, encapsulating various field properties.
-
Constructor Summary
ConstructorsConstructorDescriptionFieldDescriptor
(Identity identity, DtoOptions dtoOptions, EnumOptions enumOptions, Relationship relationship, Validation validation, SearchOptions searchOptions, Security security) Creates a FieldDescriptor instance its various properties. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns the identity of the field, which includes its name and type.Returns the list of enum values if the field is an enum.Returns the mappedBy attribute of the relationship.getName()
Returns the simple name of the field.String[]
Returns roles that are allowed to read this field.Returns the relationship type of the field.String[]
Returns the names of additional response DTO variants this field participates in.int
Returns the maximum depth for search queries on this field.Returns the list of search operators that can be used with this field.Returns the target type of the relationship.getType()
Returns theTypeMirror
of the field.List
<com.squareup.javapoet.AnnotationSpec> Returns the validation rules for the field.String[]
Returns the roles that are allowed to write to this field.boolean
Check if the field has security settings defined.int
hashCode()
Computes a hash code for the FieldDescriptor based on its properties.boolean
inDto()
Returns whether the field is included in the DTO.boolean
inRef()
Returns whether the field is included in the reference DTO.boolean
Returns whether the field is included in the request DTO.boolean
Returns whether the field is embedded.boolean
Returns whether the field is an enum.boolean
Returns whether the field is searchable.boolean
Returns whether the field is a target in a CRUD operation.toString()
Returns a string representation of the FieldDescriptor.
-
Constructor Details
-
FieldDescriptor
public FieldDescriptor(Identity identity, DtoOptions dtoOptions, EnumOptions enumOptions, Relationship relationship, Validation validation, SearchOptions searchOptions, Security security) Creates a FieldDescriptor instance its various properties.- Parameters:
identity
- the core identity of the field, including its name and typedtoOptions
- options for DTO generation, such as whether to include the field in DTOsenumOptions
- options for enum fields, such as whether the field is an enum and its possible valuesrelationship
- the relationship of the field to other entities, such as foreign keys or referencesvalidation
- validation rules for the field, such as constraints or annotationssearchOptions
- search options for the field, defining how it can be used in search queriessecurity
- security options for the field, defining access control and visibility
-
-
Method Details
-
getName
Returns the simple name of the field.- Returns:
- the simple name of the field
-
getType
Returns theTypeMirror
of the field.- Returns:
- the
TypeMirror
of the field
-
inDto
public boolean inDto()Returns whether the field is included in the DTO. This is used to determine if the field should be part of a Data Transfer Object.- Returns:
- true if the field is included in the DTO, false otherwise
-
inRequest
public boolean inRequest()Returns whether the field is included in the request DTO. This is used to determine if the field should be part of a request object.- Returns:
- true if the field is included in the request DTO, false otherwise
-
inRef
public boolean inRef()Returns whether the field is included in the reference DTO. This is used to determine if the field should be part of a reference response object.- Returns:
- true if the field is included in the reference DTO, false otherwise
-
getResponseDtos
Returns the names of additional response DTO variants this field participates in.- Returns:
- array of custom DTO identifiers
-
isEnumString
public boolean isEnumString()Returns whether the field is an enum. This is determined by the presence of enum options.- Returns:
- true if the field is an enum, false otherwise
-
getEnumValues
Returns the list of enum values if the field is an enum. This is used to provide options for enum fields in DTOs or forms.- Returns:
- a list of enum values as Strings, or an empty list if the field is not an enum
-
getRelType
Returns the relationship type of the field. This indicates how the field relates to other entities, such as one-to-one, one-to-many, etc. -
getMappedBy
Returns the mappedBy attribute of the relationship. This is used in bidirectional relationships to indicate which side owns the relationship.- Returns:
- the mappedBy attribute as a String
-
getTargetType
Returns the target type of the relationship. This is the type of the entity that this field relates to.- Returns:
- the target type as a String
-
isTargetCrud
public boolean isTargetCrud()Returns whether the field is a target in a CRUD operation. This indicates if the field is part of a relationship that can be created, read, updated, or deleted.- Returns:
- true if the field is a target in CRUD operations, false otherwise
-
isEmbedded
public boolean isEmbedded()Returns whether the field is embedded. An embedded field is one that is part of the same entity and does not have a separate table.- Returns:
- true if the field is embedded, false otherwise
-
getValidations
Returns the validation rules for the field. This includes constraints and annotations that apply to the field.- Returns:
- a Validation object containing the field's validation rules
-
isSearchable
public boolean isSearchable()Returns whether the field is searchable. This indicates if the field can be used in search queries.- Returns:
- true if the field is searchable, false otherwise
-
getSearchOperators
Returns the list of search operators that can be used with this field. These operators define how the field can be queried in search operations.- Returns:
- a list of SearchOperator objects
-
getSearchDepth
public int getSearchDepth()Returns the maximum depth for search queries on this field. This is used to limit the depth of nested searches.- Returns:
- the maximum search depth
-
hasFieldSecurity
public boolean hasFieldSecurity()Check if the field has security settings defined. -
getReadRoles
Returns roles that are allowed to read this field.- Returns:
- an array of role names that can read this field
-
getWriteRoles
Returns the roles that are allowed to write to this field.- Returns:
- an array of role names that can write to this field
-
equals
Returns the identity of the field, which includes its name and type. -
hashCode
public int hashCode()Computes a hash code for the FieldDescriptor based on its properties. -
toString
Returns a string representation of the FieldDescriptor.
-