Interface CollectibleCodec<T>

    • Method Detail

      • generateIdIfAbsentFromDocument

        T generateIdIfAbsentFromDocument​(T document)
        Generates a value for the _id field on the given document, if the document does not have one.
        Parameters:
        document - the document for which to generate a value for the _id.
        Returns:
        the document with the _id
      • documentHasId

        boolean documentHasId​(T document)
        Returns true if the given document has an _id.
        Parameters:
        document - the document in which to look for an _id
        Returns:
        true if the document has an _id
      • getDocumentId

        BsonValue getDocumentId​(T document)
        Gets the _id of the given document if it contains one, otherwise throws IllegalArgumentException. To avoid the latter case, call documentHasId first to check.
        Parameters:
        document - the document from which to get the _id
        Returns:
        the _id of the document
        Throws:
        IllegalStateException - if the document does not contain an _id