← Back to Stormify Documentation

asDefault

Registers the underlying Stormify instance as the library-wide default and caches this wrapper in StormifyJ.getDefault, so Java callers can retrieve the Java-friendly wrapper (not just the raw Stormify) via a single static call. Returns this wrapper for fluent chaining.


Runs block with this wrapper as the default, restoring the previous default when the block exits. Use for scoped overrides such as per-request tenants.

stormifyJ.asDefault(() -> {
User u = stormifyJ.attach(new User());
u.setId(42);
System.out.println(u.getName());
});

fun <R> asDefault(block: Function<StormifyJ, R>): R

Returning variant of asDefault — see the Consumer overload for semantics.