Interface Graph<T>
- Type Parameters:
T- model value type at the current graph placement
Merely resolving a detached graph by ID does not load its model value. A typed ancestor can be resolved directly
from relationship identities without loading either the source or intermediate parents. The source value, children,
history and update context are loaded only when requested, at one pinned model-state boundary. Every returned child
is itself a graph view, so root, parent, history and update operations remain available without exposing the
persistence-only Entity wrapper.
As the sole parameter of an event or notification handler, a graph subscribes to durable changes of that root and
any descendant. The handler runs once per affected root. previous() then returns the complete graph directly
before the change; a child move therefore invokes the handler once for the old root and once for the new root. One
handler object may declare separate sole-parameter methods for different Graph<T> root types; each changed
root is routed to its matching typed method.
A materialized graph retains the serialized type and revision of every root and descendant placement. The ordinary
serializer upcasts each node independently and lazily when its value is accessed; there is no graph-wide revision or
separate graph-upcaster contract. Returning a complete materialized graph from a
@HandleDocument(modelGraph = ...) handler can
persist those evolved node schemas into the derived projection without changing the authoritative Models or
relationships.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordOptional caller-imposed graph reconstruction limits. -
Method Summary
Modifier and TypeMethodDescriptiondefault Collection<?> aliases()Returns the model aliases without loading relationship context.Returns the closest ancestor, including the current graph, assignable to the requested type.default <A> Optional<A> ancestorModel(Class<A> ancestorType) Returns the value of the closest ancestor, including the current model, assignable to the requested type.Applies a complete message.apply(DeserializingMessage update) Applies a deserializing message.Applies one update to this graph's current model and returns the staged resulting graph.Applies the supplied updates in order.Applies one update with explicit metadata.apply(Collection<?> updates) Applies the supplied updates in order.assertAndApply(Object update) Verifies and applies the supplied update.assertAndApply(Object... updates) Verifies and applies the supplied updates in order.assertAndApply(Object update, io.fluxzero.common.api.Metadata metadata) Verifies and applies the supplied update with explicit metadata.assertAndApply(Collection<?> updates) Verifies and applies the supplied updates in order.assertLegal(Object update) Verifies that the supplied update is legal and returns this graph.atStateIndex(long stateIndex) Returns the same model graph reconstructed at the requested durable state boundary.default <C> List<C> childModels(Class<C> childType) Returns direct child values of the requested type.default <C> List<C> childModels(String path, Class<C> childType) Returns direct child values placed at the requested explicit relationship path.Returns the declared serialized child paths in deterministic order, including paths that currently have no children.children()Returns all direct children in deterministic relationship-path order.Returns direct children of the requested type.Returns direct children placed at the requested explicit relationship path.commit()Explicitly commits staged changes.default <C> Optional<C> Returns response context assignable to the requested type, if attached to this graph view.delete()Marks this model as deleted and returns the staged resulting graph.default <D> List<D> descendantModels(Class<D> descendantType) Returns all descendant values assignable to the requested type.default <D> List<D> descendantModels(String path, Class<D> descendantType) Returns descendant values reached through the requested relationship path.descendants(Class<D> descendantType) Returns all descendants assignable to the requested type in deterministic graph order.descendants(String path, Class<D> descendantType) Returns descendants reached through the requested relationship path.filterBranches(Predicate<? super Graph<?>> predicate) Returns an immutable response view containing every matching placement, its complete descendant branch and the ancestors needed to preserve its serialized path.filterGraph(Predicate<? super Graph<T>> predicate) Returns this graph when it matches the supplied condition.filterNodes(Predicate<? super Graph<?>> predicate) Returns an immutable, lazy view whose model values are retained only when the supplied predicate accepts their graph placement.Returns this graph only when its current model value is present.Finds a graph by exact persisted identity or alias.Finds a graph by functional identity or alias and expected model type.find(Object idOrAlias, Class<M> modelType, GraphLookupPolicy lookupPolicy) Finds a graph by functional identity or alias and expected model type using the supplied ambiguity policy.Finds the first graph in deterministic graph order matching the supplied condition.default StringReturns the public functional identity from the current model value or, for a deleted model, its latest available historical value.get()Returns the current model value, ornullfor a missing or deleted model.default booleanhasChanged(Function<? super T, ?> selector) Returns whether the selected value differs from the preceding revision.default LongReturns the newest event index retained by this graph's revision history.id()Returns the exact collision-safe repository identity of this model.ifPresent(UnaryOperator<Graph<T>> operation) Applies a graph operation only when a current model value is present.default booleanisEmpty()Returns whether this graph currently represents a missing or deleted model.default booleanReturns whether this graph currently contains a model value.default booleanisRoot()Returns whether this graph is the outer root of its current graph view.Returns the last globally published event identifier visible to this model revision.Returns the last globally published event index visible to this model revision.default <R> Optional<R> Maps the current model value when present without loading relationship context.default <R> Optional<R> Maps this graph itself without loading relationship context.default <R> Optional<R> mapIfPresent(Function<? super Graph<T>, ? extends R> mapper) Maps this graph only when its current model value is present.optional()Returns the current model value as an optional without loading relationship context.default TReturns the current model value or the supplied fallback.default TReturns the current model value or obtains a fallback lazily.default TReturns the current model value or throws when this graph is empty.orElseThrow(Supplier<? extends X> exceptionSupplier) Returns the current model value or throws the supplied exception when this graph is empty.parent()Returns the parent of this concrete graph placement, if one exists.Returns the closest parent assignable to the requested type.default <P> Optional<P> parentModel(Class<P> parentType) Returns the value of the closest parent assignable to the requested type.parents()Returns all direct parents of this model.playBackToCondition(Predicate<Graph<T>> condition) Plays back to the first retained revision matching the supplied condition.playBackToEvent(Long eventIndex, String eventId) Plays back to the first retained revision matching the supplied event boundary.previous()Returns the preceding model revision as a lazy graph, ornullwhen none is retained.default <V> VpreviousValue(Function<? super T, V> selector) Returns the selected value from the preceding revision, ornullwhen unavailable.Returns the parent-relative relationship path, ornullfor a pathless, standalone, or root view.Returns current and retained preceding revisions, newest first.default longReturns the namespace-wide state boundary at which this concrete model revision became current.Graph<?> root()Returns the outer graph root.selectPaths(String... paths) Returns an immutable graph view containing only the selected serialized relationship paths and their ancestors.selectPaths(Collection<String> paths) longReturns the model-local sequence number.longReturns the pinned namespace-wide model-state boundary.stream()Lazily traverses this graph in deterministic pre-order, including this graph itself.Returns the timestamp of this model revision.type()Returns the concrete model type.update(UnaryOperator<T> update) Updates the current value directly.withContext(Object... values) Returns an immutable graph view carrying typed response context for graph-derived properties.
-
Method Details
-
get
Returns the current model value, ornullfor a missing or deleted model. -
isPresent
default boolean isPresent()Returns whether this graph currently contains a model value. -
isEmpty
default boolean isEmpty()Returns whether this graph currently represents a missing or deleted model. -
optional
-
mapGraph
-
filterGraph
-
filterPresent
-
withContext
Returns an immutable graph view carrying typed response context for graph-derived properties.Context is shared by the complete graph view, including its parents, children and historical revisions. It does not become part of model state and is not loaded or persisted by the SDK. This makes it suitable for one response-wide, already-batched lookup that several
@GraphPropertymethods consume without introducing per-node I/O. -
context
-
mapIfPresent
-
map
-
orElse
-
orElseGet
-
orElseThrow
Returns the current model value or throws when this graph is empty. -
orElseThrow
-
ifPresent
Applies a graph operation only when a current model value is present. -
id
Object id()Returns the exact collision-safe repository identity of this model. -
functionalId
Returns the public functional identity from the current model value or, for a deleted model, its latest available historical value.This deliberately differs from
id(), which can contain anEntityIdprefix, postfix or parent scope used only for durable repository identity. A model that has never existed has no functional identity and returnsnull. -
type
-
aliases
Returns the model aliases without loading relationship context. -
relationshipPath
Returns the parent-relative relationship path, ornullfor a pathless, standalone, or root view. -
stateIndex
long stateIndex()Returns the pinned namespace-wide model-state boundary. -
revisionStateIndex
default long revisionStateIndex()Returns the namespace-wide state boundary at which this concrete model revision became current.Unlike
stateIndex(), which describes the pinned boundary shared by the complete graph, this value can differ between nodes and therefore provides a stable ordering for otherwise ambiguous functional-ID lookups. -
lastEventId
Returns the last globally published event identifier visible to this model revision. -
lastEventIndex
Returns the last globally published event index visible to this model revision. -
sequenceNumber
long sequenceNumber()Returns the model-local sequence number. -
timestamp
Instant timestamp()Returns the timestamp of this model revision. -
root
Graph<?> root()Returns the outer graph root. On a root graph this returnsthis. -
isRoot
default boolean isRoot()Returns whether this graph is the outer root of its current graph view. -
parent
-
parents
-
parent
-
parentModel
-
ancestor
-
ancestorModel
-
children
-
childPaths
-
selectPaths
Returns an immutable graph view containing only the selected serialized relationship paths and their ancestors. Model values and graph nodes are shared with this graph; no models are copied or loaded merely by creating the view. An empty selection returns this complete graph. -
selectPaths
-
filterNodes
Returns an immutable, lazy view whose model values are retained only when the supplied predicate accepts their graph placement. Rejected descendants remain structurally addressable as empty graphs but are omitted during graph serialization; accepted values are shared and never copied. A caller that retains a deep descendant should also retain its serialized ancestors. -
filterBranches
Returns an immutable response view containing every matching placement, its complete descendant branch and the ancestors needed to preserve its serialized path. This is useful for selecting independently addressed branches: matching a parent retains its whole subtree, while matching a leaf retains only that leaf and its ancestors. The graph is traversed once; retained model values are shared and never copied. -
children
-
children
-
childModels
-
childModels
-
descendants
-
descendants
-
descendantModels
-
descendantModels
-
stream
-
find
-
find
-
find
-
find
default <M> Optional<Graph<M>> find(Object idOrAlias, Class<M> modelType, GraphLookupPolicy lookupPolicy) Finds a graph by functional identity or alias and expected model type using the supplied ambiguity policy. Exact identities take precedence over aliases throughout the complete graph. -
apply
-
apply
-
apply
Applies a deserializing message. -
apply
-
apply
-
apply
Applies the supplied updates in order. -
update
Updates the current value directly. When returned by an apply interceptor, the staged update joins that interceptor's atomic model commit and is replayed against fresh state after an accepted conflict. The operator must therefore be deterministic and free of external side effects. Preferapply(Object)for domain updates whose apply-specific event publication settings should govern the transition. -
delete
-
commit
-
assertLegal
-
assertAndApply
Verifies and applies the supplied update. For an independentModel, this enters the regular model pipeline and returns after the selected model commit is durable; payload IDs do not replace this graph's explicit identity. Interceptor payload transformations retain that identity, while returning an explicitMessagestarts a separately routed update. Aggregate-backed graphs retain their surrounding aggregate lifecycle. -
assertAndApply
-
assertAndApply
-
assertAndApply
Verifies and applies the supplied updates in order. -
previous
Returns the preceding model revision as a lazy graph, ornullwhen none is retained. Surrounding models and relationships are resolved immediately before the current revision became effective. This keeps children added after the preceding root revision visible while excluding changes made by the update whose before-state is being observed. -
revisions
-
highestEventIndex
Returns the newest event index retained by this graph's revision history. -
atStateIndex
-
playBackToEvent
-
playBackToCondition
-
hasChanged
-
previousValue
-