Class SimpleSchemaField

All Implemented Interfaces:
DiffGenerating<SimpleSchemaField>, Cloneable
Direct Known Subclasses:
AbstractEnumSchemaField, ReferenceSchemaField

public class SimpleSchemaField extends SchemaField implements DiffGenerating<SimpleSchemaField>
A simple field in a SchemaObjectType.
  • Field Details

    • ITEM_TYPE

      public static final ItemType ITEM_TYPE
      The ItemType that this class represents.
  • Constructor Details

    • SimpleSchemaField

      public SimpleSchemaField()
  • Method Details

    • getFullName

      public String getFullName()
      Get the full name of this field.

      If the 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:
      this field's full name
    • getParent

      public ComplexSchemaField getParent()
      Get the parent field if this is a sub-field of a ComplexSchemaField.
      Returns:
      parent field, or null if this is not a sub-field
    • setParent

      public final void setParent(ComplexSchemaField parent)
      Set the parent complex field.

      Note: this field is considered derived information, and will be set automatically when a containing SchemaObjectType or ComplexSchemaField is locked down.

      Parameters:
      parent - complex field parent of this field, or null if this field is not a sub-field
      Throws:
      UnsupportedOperationException - if this instance is locked down
    • getEncodingId

      public EncodingId getEncodingId()
      Get the EncodingId that identifies how this field's values are encoded.
      Returns:
      field encoding ID
    • setEncodingId

      public void setEncodingId(EncodingId encodingId)
      Set the EncodingId that identifies how this field's values are encoded.
      Parameters:
      encodingId - field encoding ID
      Throws:
      UnsupportedOperationException - if this instance is locked down
    • isIndexed

      public boolean isIndexed()
      Get whether this field is indexed.
      Returns:
      true if this field is indexed
    • setIndexed

      public void setIndexed(boolean indexed)
      Set whether this field is indexed.
      Parameters:
      indexed - true if this field is indexed, otherwise false
      Throws:
      UnsupportedOperationException - if this instance is locked down
    • hasFixedEncoding

      public boolean hasFixedEncoding()
      Determine if this field has a fixed encoding.
      Returns:
      true if this is a ReferenceSchemaField or AbstractEnumSchemaField, otherwise false
    • isAlwaysIndexed

      public boolean isAlwaysIndexed()
      Determine if this field is always indexed.
      Returns:
      true if this is a ReferenceSchemaField, otherwise false
    • visit

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

      public ItemType getItemType()
      Get the ItemType corresponding to this instance.
      Returns:
      schema item type
    • differencesFrom

      public Diffs differencesFrom(SimpleSchemaField that)
      Description copied from interface: DiffGenerating
      Detect the differences of this instance when compared to the given instance.
      Specified by:
      differencesFrom in interface DiffGenerating<SimpleSchemaField>
      Parameters:
      that - other instance
      Returns:
      differences; will be empty if there are none detected
    • toString

      public String toString()
      Overrides:
      toString in class SchemaField
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class SchemaItem
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class SchemaItem
    • clone

      public SimpleSchemaField clone()
      Deep-clone this instance.

      The returned instance will not be locked down even if this one is.

      Overrides:
      clone in class SchemaField
    • getObjectType

      public SchemaObjectType getObjectType()
      Get the SchemaObjectType of which this field is a member.
      Returns:
      containing object type
    • setObjectType

      public final void setObjectType(SchemaObjectType objectType)
      Set the SchemaObjectType of which this field is a member.

      Note: this field is considered derived information, and will be set automatically when a referrring SchemaObjectType is locked down.

      Parameters:
      objectType - containing object type
      Throws:
      UnsupportedOperationException - if this instance is locked down
    • visitSchemaItems

      public void visitSchemaItems(Consumer<? super SchemaItem> visitor)
      Visit all SchemaItem descendents of this instance with the given visitor.

      If this instance is also a SchemaItem, then also visit this instance.

      The traversal is depth first, pre-order.

      Parameters:
      visitor - visitor for schema items
      Throws:
      IllegalArgumentException - if visitor is null
    • visitSchemaItems

      public final <T extends SchemaItem> void visitSchemaItems(Class<T> nodeType, Consumer<? super T> visitor)
      Visit this schema item and all of its descendents matching the given type with the given visitor.

      The traversal is depth first, post-order.

      Parameters:
      nodeType - node type to include
      visitor - visitor for schema items
      Throws:
      IllegalArgumentException - if either parameter is null
    • isLockedDown

      public final boolean isLockedDown(boolean includingStorageIds)
      Determine whether this instance is locked down.
      Parameters:
      includingStorageIds - false to test all but storage ID's, true to require storage ID's to be locked down as well
      Returns:
      true if instance is locked down, otherwise false
    • getSchemaId

      public final SchemaId getSchemaId()
      Generate a unique SchemaId corresponding to the type and encoding structure of this schema item.

      The SchemaId does not depend on the storage ID.

      This instance must be locked down except for storage ID's. Repeated invocations of this method will be very fast, just returning the cached previous result.

      Returns:
      schema ID
      Throws:
      IllegalStateException - if this instance is not locked down
      See Also: