Interface CosIdAccessor
- All Superinterfaces:
CosIdGetter,CosIdSetter,EnsureId,IdMetadata
- All Known Implementing Classes:
CosIdAccessor.NotFound,DefaultCosIdAccessor
This interface combines multiple capabilities for working with ID fields in objects:
CosIdGetter- Getting ID values from objectsCosIdSetter- Setting ID values on objectsIdMetadata- Providing metadata about ID fieldsEnsureId- Ensuring objects have IDs assigned
The accessor is used by the CosId framework to automatically find and populate ID fields in objects when they are persisted or processed. This enables a "convention over configuration" approach where ID fields are automatically detected and populated without explicit code.
The interface includes utility methods for checking ID type compatibility and ensuring reflective access to fields.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classSentinel implementation representing a "not found" accessor. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final CosIdAccessor.NotFoundA sentinel value representing a "not found" accessor. -
Method Summary
Static MethodsModifier and TypeMethodDescriptionstatic booleanavailableType(Class<?> idType) Check if the specified ID type is supported by CosId.static voidensureAccessible(AccessibleObject accessibleObject) Ensure that the specified accessible object (field/method) is accessible.Methods inherited from interface me.ahoo.cosid.accessor.CosIdGetter
getIdMethods inherited from interface me.ahoo.cosid.accessor.CosIdSetter
setIdMethods inherited from interface me.ahoo.cosid.accessor.IdMetadata
getGeneratorName, getIdDeclaringClass, getIdDefinition, getIdField, getIdGenerator, getIdType
-
Field Details
-
NOT_FOUND
A sentinel value representing a "not found" accessor.This is used when no valid ID field can be found in an object, allowing the framework to handle missing ID fields gracefully without null checks.
-
-
Method Details
-
availableType
Check if the specified ID type is supported by CosId.This method verifies that the provided ID type is one of the supported types for automatic ID injection:
- Parameters:
idType- The ID type to check- Returns:
trueif the type is supported,falseotherwise
-
ensureAccessible
Ensure that the specified accessible object (field/method) is accessible.This utility method makes the provided accessible object accessible if it is not already, allowing the framework to access private or protected fields and methods for ID injection.
- Parameters:
accessibleObject- The object to make accessible
-