Class FieldDescriptor

java.lang.Object
nl.datasteel.crudcraft.codegen.descriptor.field.FieldDescriptor

public class FieldDescriptor extends Object
Represents a field in a model, encapsulating various field properties.
  • 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 type
      dtoOptions - options for DTO generation, such as whether to include the field in DTOs
      enumOptions - options for enum fields, such as whether the field is an enum and its possible values
      relationship - the relationship of the field to other entities, such as foreign keys or references
      validation - validation rules for the field, such as constraints or annotations
      searchOptions - search options for the field, defining how it can be used in search queries
      security - security options for the field, defining access control and visibility
  • Method Details

    • getName

      public String getName()
      Returns the simple name of the field.
      Returns:
      the simple name of the field
    • getType

      public TypeMirror getType()
      Returns the TypeMirror 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

      public String[] 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

      public List<String> 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

      public RelationshipType 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

      public String 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

      public 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

      public List<com.squareup.javapoet.AnnotationSpec> 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

      public List<SearchOperator> 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

      public String[] getReadRoles()
      Returns roles that are allowed to read this field.
      Returns:
      an array of role names that can read this field
    • getWriteRoles

      public String[] 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

      public boolean equals(Object obj)
      Returns the identity of the field, which includes its name and type.
      Overrides:
      equals in class Object
      Returns:
      the Identity object representing the field's identity
    • hashCode

      public int hashCode()
      Computes a hash code for the FieldDescriptor based on its properties.
      Overrides:
      hashCode in class Object
      Returns:
      an integer hash code
    • toString

      public String toString()
      Returns a string representation of the FieldDescriptor.
      Overrides:
      toString in class Object
      Returns:
      a string containing the field's name, type, and various options