Package net.minestom.server.snapshot
Interface SnapshotUpdater
@Experimental
public sealed interface SnapshotUpdater
Represents the context of a snapshot build.
Used in
Snapshotable.updateSnapshot(SnapshotUpdater)
to create snapshot references and avoid circular dependencies.
Updaters must never leave scope, as its data may be state related (change according to the currently processed snapshot).
Implementations do not need to be thread-safe and cannot be re-used.
-
Method Summary
Modifier and TypeMethodDescriptiondefault <T extends Snapshot>
AtomicReference<T> optionalReference
(Snapshotable snapshotable) <T extends Snapshot>
@NotNull AtomicReference<T> reference
(@NotNull Snapshotable snapshotable) default <T extends Snapshot,
S extends Snapshotable, K>
@NotNull Map<K, AtomicReference<T>> referencesMap
(@NotNull Collection<S> snapshotables, @NotNull Function<S, K> mappingFunction) default <T extends Snapshot,
S extends Snapshotable>
@NotNull Map<Integer, AtomicReference<T>> referencesMapInt
(@NotNull Collection<S> snapshotables, @NotNull ToIntFunction<S> mappingFunction) default <T extends Snapshot,
S extends Snapshotable>
@NotNull Map<Long, AtomicReference<T>> referencesMapLong
(@NotNull Collection<S> snapshotables, @NotNull ToLongFunction<S> mappingFunction) static <T extends Snapshot>
Tupdate
(@NotNull Snapshotable snapshotable) Updates the snapshot of the given snapshotable.
-
Method Details
-
update
Updates the snapshot of the given snapshotable.Method must be called during a safe-point (when the server state is stable).
- Type Parameters:
T
- the snapshot type- Parameters:
snapshotable
- the snapshot container- Returns:
- the new updated snapshot
-
reference
@NotNull <T extends Snapshot> @NotNull AtomicReference<T> reference(@NotNull @NotNull Snapshotable snapshotable) -
optionalReference
@Contract("!null -> !null") default <T extends Snapshot> AtomicReference<T> optionalReference(Snapshotable snapshotable) -
referencesMap
@NotNull default <T extends Snapshot,S extends Snapshotable, @NotNull Map<K,K> AtomicReference<T>> referencesMap(@NotNull @NotNull Collection<S> snapshotables, @NotNull @NotNull Function<S, K> mappingFunction) -
referencesMapLong
@NotNull default <T extends Snapshot,S extends Snapshotable> @NotNull Map<Long,AtomicReference<T>> referencesMapLong(@NotNull @NotNull Collection<S> snapshotables, @NotNull @NotNull ToLongFunction<S> mappingFunction) -
referencesMapInt
@NotNull default <T extends Snapshot,S extends Snapshotable> @NotNull Map<Integer,AtomicReference<T>> referencesMapInt(@NotNull @NotNull Collection<S> snapshotables, @NotNull @NotNull ToIntFunction<S> mappingFunction)
-