microstream
microstream copied to clipboard
Throw NotConnectedToRootException
Is your feature request related to a problem? Please describe.
It is possible to store objects in the storage, even if they have no connection to any root-object. This means i can write code like this:
public class Demo
{
private static record MyRoot(){}
private static record MyUnrelatedClass(){}
public static void main(String[] args)
{
MyRoot root = new MyRoot();
EmbeddedStorageManager storageManager = EmbeddedStorage.start(root);
MyUnrelatedClass unrelatedInstance = new MyUnrelatedClass();
storageManager.store(unrelatedInstance);
}
}
There are more complicated constructs, where something like this occures.
Describe the solution you'd like
Throw an exception if a not-connected entity should be stored (perhaps something like NotConnectedToRootException
).
Describe alternatives you've considered
I guess you can somehow check the long-value that's returned at store
to see if it was stored, but i don't know and i don't think this is intuitive way of doing this.