Class AbstractIdMetadata

java.lang.Object
me.ahoo.cosid.accessor.AbstractIdMetadata
All Implemented Interfaces:
IdMetadata
Direct Known Subclasses:
DefaultCosIdAccessor

public abstract class AbstractIdMetadata extends Object implements IdMetadata
Abstract base implementation of IdMetadata.

Provides common functionality for ID metadata implementations, including lazy generator initialization.

  • Constructor Details

    • AbstractIdMetadata

      public AbstractIdMetadata(IdDefinition idDefinition)
      Creates an instance with the given ID definition, resolving generators from DefaultIdGeneratorProvider.INSTANCE.
      Parameters:
      idDefinition - the ID definition
    • AbstractIdMetadata

      public AbstractIdMetadata(IdDefinition idDefinition, IdGeneratorProvider idGeneratorProvider)
      Creates an instance with the given ID definition and provider.
      Parameters:
      idDefinition - the ID definition
      idGeneratorProvider - the provider used to resolve the generator
  • Method Details

    • getIdDefinition

      public IdDefinition getIdDefinition()
      Description copied from interface: IdMetadata
      Gets the ID definition.
      Specified by:
      getIdDefinition in interface IdMetadata
      Returns:
      the ID definition
    • getIdGenerator

      public IdGenerator getIdGenerator()
      Description copied from interface: IdMetadata
      Gets the ID generator.
      Specified by:
      getIdGenerator in interface IdMetadata
      Returns:
      the ID generator
    • checkGeneratorSupportsIdType

      protected void checkGeneratorSupportsIdType(boolean required)
      Checks that the ID generator, if it is already registered (or, with required, always), can generate the type of the id field: a long or int field needs an IdGenerator, not a generator of string ids only.
      Parameters:
      required - whether a missing generator fails too
      Throws:
      CosIdException - naming the field and the generator if they do not fit