public interface DocumentIdResolver
Path
type Property
within a PropertySet
which can act as
document identifier property.Modifier and Type | Method and Description |
---|---|
<T> T |
decode(org.bson.types.ObjectId id,
Class<? extends T> type)
Decode given
ObjectId using given type. |
org.bson.types.ObjectId |
encode(Object documentId)
Encode given document id as an
ObjectId . |
static DocumentIdResolver |
getDefault()
Get the default
DocumentIdResolver implementation. |
boolean |
isValidDocumentIdType(Class<?> type)
Checks if the given type is a valid document id type.
|
boolean |
isValidDocumentIdType(com.holonplatform.core.property.Property<?> property)
Checks if the type of given property is a valid document id type.
|
Optional<com.holonplatform.core.Path<?>> |
resolveDocumentIdPath(com.holonplatform.core.property.PropertySet<?> propertySet)
Try to resolve the
Path within given PropertySet which can act as document identifier
path property. |
Optional<com.holonplatform.core.property.Property<?>> |
resolveDocumentIdProperty(com.holonplatform.core.property.PropertySet<?> propertySet)
Try to resolve the
Property within given PropertySet which can act as document
identifier property. |
Optional<com.holonplatform.core.property.Property<?>> resolveDocumentIdProperty(com.holonplatform.core.property.PropertySet<?> propertySet) throws InvalidDocumentIdentifierException
Property
within given PropertySet
which can act as document
identifier property.propertySet
- The property set (not null)InvalidDocumentIdentifierException
- If an error occurred during document identifier property resolutionOptional<com.holonplatform.core.Path<?>> resolveDocumentIdPath(com.holonplatform.core.property.PropertySet<?> propertySet) throws InvalidDocumentIdentifierException
Path
within given PropertySet
which can act as document identifier
path property.propertySet
- The property set (not null)InvalidDocumentIdentifierException
- If an error occurred during document identifier property resolutionorg.bson.types.ObjectId encode(Object documentId) throws InvalidDocumentIdentifierException
ObjectId
.documentId
- The document id to encodeObjectId
, null
if given document id was null
InvalidDocumentIdentifierException
- If the given document id is not encodable<T> T decode(org.bson.types.ObjectId id, Class<? extends T> type) throws InvalidDocumentIdentifierException
ObjectId
using given type.T
- Expected value typeid
- The id to decodetype
- The decoding type (not null)null
if given id was null
InvalidDocumentIdentifierException
- If the given type is not decodableboolean isValidDocumentIdType(com.holonplatform.core.property.Property<?> property)
property
- Property to checktrue
if the type of given property is a valid document id type, false
otherwiseboolean isValidDocumentIdType(Class<?> type)
type
- Type to checktrue
if the given type is a valid document id type, false
otherwisestatic DocumentIdResolver getDefault()
DocumentIdResolver
implementation.
The admitted identifier property types are: String
, BigInteger
and ObjectId
.
The default DocumentIdResolver
implementation looks for a Path
type Property
with the
_id
path name, first of all in the identifier property set, if available (see
PropertySet.getIdentifiers()
), or in the overall property set.
If more than one property with the _id
path name is found, or if the identifier property type is not
admitted, an InvalidDocumentIdentifierException
is thrown.
DocumentIdResolver
implementationCopyright © 2019 The Holon Platform. All rights reserved.