Class SingleReference<T>

  • Type Parameters:
    T -

    public class SingleReference<T>
    extends MorphiaReference<T>
    Developer note.
    This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
    • Constructor Detail

      • SingleReference

        public SingleReference​(Datastore datastore,
                               MappedClass mappedClass,
                               Object id)
        Parameters:
        datastore - the datastore to use
        mappedClass - the entity's mapped class
        id - the ID value
        Developer note.
        This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
    • Method Detail

      • decode

        public static MorphiaReference<?> decode​(Datastore datastore,
                                                 Mapper mapper,
                                                 MappedField mappedField,
                                                 Class paramType,
                                                 org.bson.Document document)
        Decodes a document in to an entity
        Parameters:
        datastore - the datastore
        mapper - the mapper
        mappedField - the MappedField
        paramType - the type of the underlying entity
        document - the Document to decode
        Returns:
        the entity
      • get

        public T get()
        Specified by:
        get in class MorphiaReference<T>
        Returns:
        returns the referenced entity if it exists. May return null.
      • encode

        public Object encode​(Mapper mapper,
                             Object value,
                             MappedField optionalExtraInfo)
        Specified by:
        encode in class MorphiaReference<T>
        Parameters:
        mapper - the mapper
        value - the value
        optionalExtraInfo - the MappedField
        Returns:
        the encoded vale