Interface ObjectConstructor

  • All Superinterfaces:
    ObjectTranslator
    All Known Implementing Classes:
    TClass, TSerializable, TTransient, TTreeMap, TTreeSet

    public interface ObjectConstructor
    extends ObjectTranslator
    interface to allow instantiating objects by calling specific constructors.

    By writing classes that implement this interface, it is possible to define which constructor is to be used during the instantiation of a stored object.

    Before starting a db4o session, translator classes that implement the ObjectConstructor or ObjectTranslator need to be registered.

    Example:
    EmbeddedConfiguration config = Db4oEmbedded.newConfiguration();
    ObjectClass oc = config.common().objectClass("package.className");
    oc.translate(new FooTranslator());


    • Method Detail

      • onInstantiate

        java.lang.Object onInstantiate​(ObjectContainer container,
                                       java.lang.Object storedObject)
        db4o calls this method when a stored object needs to be instantiated.

        Parameters:
        container - the ObjectContainer used
        storedObject - the object stored with ObjectTranslator.onStore.
        Returns:
        the instantiated object.