Class Snapshot

java.lang.Object
org.apache.juneau.commons.inject.Snapshot

public final class Snapshot extends Object
Opaque handle for a single pushed overlay frame on a WritableBeanStore.

A Snapshot is returned by WritableBeanStore.pushOverlay(BeanStore) and must be passed back to WritableBeanStore.popOverlay(Snapshot) to remove the corresponding frame. The type intentionally exposes no public state: tests treat it as a token, the implementation uses it to enforce LIFO discipline and reject cross-store pops.

Instances cannot be constructed externally — only pushOverlay(...) produces them. Equality is identity-based; two distinct push operations always produce distinct snapshots, even when the overlay and the owning store are the same.

Example:

WritableBeanStore store = ...; BeanStore overlay = new BasicBeanStore().addBean(MyService.class, mock); Snapshot snap = store.pushOverlay(overlay); try { // overlay active here } finally { store.popOverlay(snap); }

See Also:
  • WritableBeanStore - The interface that produces and consumes Snapshot instances.
  • StackOverlay - The underlying stack-overlay primitive BasicBeanStore composes with.
Since:
10.0.0