Package io.permazen

Class PermazenSimpleField

Direct Known Subclasses:
PermazenEnumArrayField, PermazenEnumField, PermazenReferenceField

public class PermazenSimpleField extends PermazenField
Represents a simple field in a PermazenClass or a simple sub-field of a complex field in a PermazenClass.
  • Method Details

    • getDeclaringAnnotation

      public PermazenField getDeclaringAnnotation()
      Description copied from class: PermazenField
      Get the Annotation that declared this field.

      If this field was auto-generated from an abstract method with no annotation, a non-null Annotation is still returned; it will have all default values.

      Overrides:
      getDeclaringAnnotation in class PermazenField
      Returns:
      declaring annotation
    • getFullName

      public String getFullName()
      Description copied from class: PermazenField
      Get the "full name" of this field.u

      If this field is a sub-field of a complex field, the full name is the field's name qualified by the parent field name, e.g., "mymap.key". Otherwise, the full is is the same as the name.

      Overrides:
      getFullName in class PermazenField
      Returns:
      parent PermazenComplexField, or null if this instance is not a sub-field
    • isSubField

      public boolean isSubField()
      Determine whether this field is a sub-field of a PermazenComplexField.
      Returns:
      true if this field is a sub-field, otherwise false
    • getParentField

      public PermazenComplexField getParentField()
      Get the PermazenComplexField of which this instance is a sub-field, if any.
      Returns:
      parent PermazenComplexField, or null if this instance is not a sub-field
    • getTypeToken

      public TypeToken<?> getTypeToken()
      Get the type of this field.
      Specified by:
      getTypeToken in class PermazenField
      Returns:
      this field's Java type
    • getEncoding

      public Encoding<?> getEncoding()
      Get the Encoding used by the core API to encode this field's values.

      Note that for Enum and reference fields, the core API uses a different type than the Java model classes (EnumValue and ObjId, respectively). Values can always be properly converted using the Converter returned by getConverter().

      Returns:
      this field's core-layer type definition
    • isIndexed

      public boolean isIndexed()
      Get whether this field is indexed.
      Returns:
      whether this field is indexed
    • getIndex

      public Index1<?,?> getIndex(PermazenTransaction ptx)
      View the index on this field.
      Parameters:
      ptx - transaction
      Returns:
      view of the index on this field in tx
      Throws:
      StaleTransactionException - if tx is no longer usable
      IllegalArgumentException - if this field is not indexed
      IllegalArgumentException - if tx is null
    • getSetter

      public Method getSetter()
      Get the setter method associated with this field.
      Returns:
      field property setter method, or null if this field is a sub-field of a complex field
    • getValue

      public Object getValue(PermazenObject pobj)
      Description copied from class: PermazenField
      Get the Java value of this field in the given Java model object. Does not alter the schema of the object.
      Specified by:
      getValue in class PermazenField
      Parameters:
      pobj - object containing this field
      Returns:
      this field's value in pobj
    • visit

      public <R> R visit(PermazenFieldSwitch<R> target)
      Description copied from class: PermazenField
      Apply visitor pattern.
      Specified by:
      visit in class PermazenField
      Type Parameters:
      R - visit return type
      Parameters:
      target - target to invoke
      Returns:
      value from the method of target corresponding to this instance's type
    • getConverter

      public Converter<?,?> getConverter(PermazenTransaction ptx)
      Description copied from class: PermazenField
      Get a Converter that converts this field's value from what the core database returns to what the Java application expects, or null if no conversion is needed.
      Specified by:
      getConverter in class PermazenField
      Parameters:
      ptx - transaction
      Returns:
      Converter from core API to Java, or null if no conversion is required
    • setValue

      public void setValue(PermazenObject pobj, Object value)
      Set the Java value of this field in the given object. Does not alter the schema of the object.
      Parameters:
      pobj - object containing this field
      value - new value
      Throws:
      DeletedObjectException - if pobj does not exist in its associated PermazenTransaction
      StaleTransactionException - if the PermazenTransaction associated with pobj is no longer usable
      IllegalArgumentException - if this field is a sub-field of a complex field
      IllegalArgumentException - if value is not an appropriate value for this field
      IllegalArgumentException - if pobj is null
    • getSchemaItem

      public SimpleField<?> getSchemaItem()
      Description copied from class: PermazenSchemaItem
      Get the corresonding core API database instance.
      Overrides:
      getSchemaItem in class PermazenField
      Returns:
      this instance's correpsonding SchemaItem