Package me.ahoo.cosid.accessor
Class AbstractIdMetadata
java.lang.Object
me.ahoo.cosid.accessor.AbstractIdMetadata
- All Implemented Interfaces:
IdMetadata
- Direct Known Subclasses:
DefaultCosIdAccessor
Abstract base implementation of
IdMetadata.
Provides common functionality for ID metadata implementations, including lazy generator initialization.
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractIdMetadata(IdDefinition idDefinition) Creates an instance with the given ID definition, resolving generators fromDefaultIdGeneratorProvider.INSTANCE.AbstractIdMetadata(IdDefinition idDefinition, IdGeneratorProvider idGeneratorProvider) Creates an instance with the given ID definition and provider. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckGeneratorSupportsIdType(boolean required) Checks that the ID generator, if it is already registered (or, withrequired, always), can generate the type of the id field: alongorintfield needs anIdGenerator, not a generator of string ids only.Gets the ID definition.Gets the ID generator.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface me.ahoo.cosid.accessor.IdMetadata
getGeneratorName, getIdDeclaringClass, getIdField, getIdType
-
Constructor Details
-
AbstractIdMetadata
Creates an instance with the given ID definition, resolving generators fromDefaultIdGeneratorProvider.INSTANCE.- Parameters:
idDefinition- the ID definition
-
AbstractIdMetadata
Creates an instance with the given ID definition and provider.- Parameters:
idDefinition- the ID definitionidGeneratorProvider- the provider used to resolve the generator
-
-
Method Details
-
getIdDefinition
Description copied from interface:IdMetadataGets the ID definition.- Specified by:
getIdDefinitionin interfaceIdMetadata- Returns:
- the ID definition
-
getIdGenerator
Description copied from interface:IdMetadataGets the ID generator.- Specified by:
getIdGeneratorin interfaceIdMetadata- Returns:
- the ID generator
-
checkGeneratorSupportsIdType
protected void checkGeneratorSupportsIdType(boolean required) Checks that the ID generator, if it is already registered (or, withrequired, always), can generate the type of the id field: alongorintfield needs anIdGenerator, 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
-