Package me.ahoo.cosid.accessor
Class DefaultCosIdAccessor
java.lang.Object
me.ahoo.cosid.accessor.AbstractIdMetadata
me.ahoo.cosid.accessor.DefaultCosIdAccessor
- All Implemented Interfaces:
CosIdAccessor,CosIdGetter,CosIdSetter,EnsureId,IdMetadata
Default
CosIdAccessor implementation.
Provides ID get/set operations on entities and ensures IDs are generated when missing. Supports Long, Integer, and String ID types.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassEnsures ID is generated for Integer ID types.classEnsures ID is generated for Long ID types.classEnsures ID is generated for String ID types.Nested classes/interfaces inherited from interface me.ahoo.cosid.accessor.CosIdAccessor
CosIdAccessor.NotFound -
Field Summary
Fields inherited from interface me.ahoo.cosid.accessor.CosIdAccessor
NOT_FOUND -
Constructor Summary
ConstructorsConstructorDescriptionDefaultCosIdAccessor(IdDefinition idDefinition, CosIdGetter getter, CosIdSetter setter) Creates a new accessor. -
Method Summary
Modifier and TypeMethodDescriptionbooleanEnsure that the target object has an ID set.Gets the getter.Gets the ID value from the target object.Gets the setter.voidSets the ID value on the target object.Methods inherited from class me.ahoo.cosid.accessor.AbstractIdMetadata
getIdDefinition, getIdGeneratorMethods 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, getIdDefinition, getIdField, getIdGenerator, getIdType
-
Constructor Details
-
DefaultCosIdAccessor
Creates a new accessor.- Parameters:
idDefinition- the ID definitiongetter- the getter for extracting ID from entitiessetter- the setter for setting ID on entities
-
-
Method Details
-
getId
Description copied from interface:CosIdGetterGets the ID value from the target object.- Specified by:
getIdin interfaceCosIdGetter- Parameters:
target- the object to get ID from- Returns:
- the ID value
-
setId
Description copied from interface:CosIdSetterSets the ID value on the target object.- Specified by:
setIdin interfaceCosIdSetter- Parameters:
target- the object to set ID onid- the ID value to set
-
getGetter
Gets the getter.- Returns:
- the getter
-
getSetter
Gets the setter.- Returns:
- the setter
-
ensureId
Description copied from interface:EnsureIdEnsure that the target object has an ID set.
-