Package io.permazen

Class PermazenField

Direct Known Subclasses:
PermazenComplexField, PermazenCounterField, PermazenSimpleField

public abstract class PermazenField extends PermazenSchemaItem
Represents a field in a Java model object.
  • Method Details

    • getFullName

      public String getFullName()
      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.

      Returns:
      parent PermazenComplexField, or null if this instance is not a sub-field
    • getGetter

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

      public Annotation getDeclaringAnnotation()
      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.

      Returns:
      declaring annotation
    • getValue

      public abstract Object getValue(PermazenObject pobj)
      Get the Java value of this field in the given Java model object. Does not alter the schema of the object.
      Parameters:
      pobj - object containing this field
      Returns:
      this field's value in pobj
      Throws:
      DeletedObjectException - if pobj does not exist in its associated PermazenTransaction
      StaleTransactionException - if the PermazenTransaction associated with pobj is no longer usable
      IllegalArgumentException - if pobj is null
      IllegalArgumentException - if this field is a sub-field of a complex field
    • getKey

      public byte[] getKey(PermazenObject pobj)
      Get the byte[] key in the underlying key/value store corresponding to this field in the specified object.

      Notes:

      • Complex fields utilize multiple keys; the return value is the common prefix of all such keys.
      • The KVDatabase should not be modified directly, otherwise behavior is undefined
      Parameters:
      pobj - Java model object
      Returns:
      the corresonding KVDatabase key or key prefix
      Throws:
      IllegalArgumentException - if pobj is null or has the wrong object type
    • visit

      public abstract <R> R visit(PermazenFieldSwitch<R> target)
      Apply visitor pattern.
      Type Parameters:
      R - visit return type
      Parameters:
      target - target to invoke
      Returns:
      value from the method of target corresponding to this instance's type
      Throws:
      IllegalArgumentException - if target is null
    • getConverter

      public abstract Converter<?,?> getConverter(PermazenTransaction ptx)
      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.
      Parameters:
      ptx - transaction
      Returns:
      Converter from core API to Java, or null if no conversion is required
    • getTypeToken

      public abstract TypeToken<?> getTypeToken()
      Get the type of this field.
      Returns:
      this field's type
    • getPermazenClass

      public PermazenClass<?> getPermazenClass()
      Get the PermazenClass of which this field is a member.
      Returns:
      this field's containing object type
    • getSchemaItem

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