Class IdentityUtils
java.lang.Object
org.datanucleus.identity.IdentityUtils
Series of utilities for handling identities of objects.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectgetApplicationIdentityForResultSetRow(ExecutionContext ec, AbstractClassMetaData cmd, Class pcClass, boolean inheritanceCheck, FieldManager resultsFM) Method to return the object application identity for a row of the result set.static ClassAccessor for the type of the single field application-identity key given the single field identity type.static ObjectgetObjectFromIdString(String idStr, AbstractClassMetaData cmd, ExecutionContext ec, boolean checkInheritance) Convenience method to find an object given a string form of its identity, and the metadata for the class (or a superclass).static ObjectgetObjectFromIdString(String idStr, AbstractMemberMetaData mmd, FieldRole fieldRole, ExecutionContext ec, boolean checkInheritance) Convenience method to find an object given a string form of its identity, and the metadata for the member.static ObjectgetObjectFromPersistableIdentity(String persistableId, AbstractClassMetaData cmd, ExecutionContext ec) Convenience method to find an object given a string form of its identity, and the metadata for the class (or a superclass).static StringMethod to return a persistable form of the identity of a persistable object.static Class<? extends SingleFieldId> static StringMethod to return the target class name of the persistable object that the provided identity represents.static ObjectAccessor for the key object for the specified datastore-identity.static ObjectAccessor for the key object for the specified single field application-identity.static ObjectgetValueForMemberInId(Object id, AbstractMemberMetaData pkMmd) Convenience method that interrogates a user-supplied object identity and returns the value of a particular member in that id.static booleanAccessor for whether the provided id is datastore identity.static booleanAccessor for whether the passed identity is a valid single-field application-identity for this API.static booleanisSingleFieldIdentityClass(String className) Checks whether the passed class name is valid for a single field application-identity.
-
Constructor Details
-
IdentityUtils
public IdentityUtils()
-
-
Method Details
-
isSingleFieldIdentityClass
Checks whether the passed class name is valid for a single field application-identity.- Parameters:
className- the identity class name- Returns:
- Whether it is a single field class
-
getTargetClassNameForIdentity
Method to return the target class name of the persistable object that the provided identity represents. For the cases of datastore-identity or single-field identity then utilises the accessor method on those identity types to get the targetClassName. For user-provided identity types checks for atargetClassName
field and returns it if present. Otherwise returns null.- Parameters:
id- The identity- Returns:
- Class name for the identity if easily determinable
-
isSingleFieldIdentity
Accessor for whether the passed identity is a valid single-field application-identity for this API.- Parameters:
id- The id- Returns:
- Whether it is valid
-
isDatastoreIdentity
Accessor for whether the provided id is datastore identity.- Parameters:
id- The identity to check- Returns:
- Whether it is datastore identity
-
getTargetKeyForSingleFieldIdentity
-
getTargetKeyForDatastoreIdentity
-
getSingleFieldIdentityTypeForKeyType
-
getKeyTypeForSingleFieldIdentityType
-
getPersistableIdentityForId
Method to return a persistable form of the identity of a persistable object. This can be used by datastores that don't use foreign keys and want to store the explicit class of the persistable object.- Parameters:
id- The id- Returns:
- String form
-
getObjectFromPersistableIdentity
public static Object getObjectFromPersistableIdentity(String persistableId, AbstractClassMetaData cmd, ExecutionContext ec) Convenience method to find an object given a string form of its identity, and the metadata for the class (or a superclass).- Parameters:
persistableId- The persistable idcmd- (Root) metadata for the classec- Execution Context- Returns:
- The object
-
getApplicationIdentityForResultSetRow
public static Object getApplicationIdentityForResultSetRow(ExecutionContext ec, AbstractClassMetaData cmd, Class pcClass, boolean inheritanceCheck, FieldManager resultsFM) Method to return the object application identity for a row of the result set. If the class isn't using application identity then returns null- Parameters:
ec- Execution Contextcmd- Metadata for the classpcClass- The class requiredinheritanceCheck- Whether need an inheritance check (may be for a subclass)resultsFM- FieldManager servicing the results- Returns:
- The identity (if found) or null (if either not sure of inheritance, or not known).
-
getValueForMemberInId
Convenience method that interrogates a user-supplied object identity and returns the value of a particular member in that id. A user-supplied PK has to provide either public/package/protected fields with the same names as the owning class, or getters for bean properties of the same name as the class members.- Parameters:
id- The (user-defined) identitypkMmd- Metadata for the member that we require the value for- Returns:
- The value for this member in the id
-
getObjectFromIdString
public static Object getObjectFromIdString(String idStr, AbstractClassMetaData cmd, ExecutionContext ec, boolean checkInheritance) Convenience method to find an object given a string form of its identity, and the metadata for the class (or a superclass). Developers should move to using "persistable identity" and method getObjectFromPersistableIdentity().- Parameters:
idStr- The id stringcmd- Metadata for the classec- Execution ContextcheckInheritance- Whether to check the inheritance level of this object- Returns:
- The object
-
getObjectFromIdString
public static Object getObjectFromIdString(String idStr, AbstractMemberMetaData mmd, FieldRole fieldRole, ExecutionContext ec, boolean checkInheritance) Convenience method to find an object given a string form of its identity, and the metadata for the member.- Parameters:
idStr- The id stringmmd- Metadata for the memberfieldRole- Role of this field (see org.datanucleus.metadata.FieldRole)ec- Execution ContextcheckInheritance- Whether to check the inheritance level of this object- Returns:
- The object
-