Class WidgetSnapshot
- All Implemented Interfaces:
Identifiable
This is the full contract behind the revision-pinned native live-widget
bridge. The older Widget model carried geometry but dropped the
ordered action slots and the dynamic child index the adapter publishes,
while its parser defaulted absent geometry to (0, 0, 0, 0) and
absent visibility to true. Both defaults turned "the adapter did
not say" into a confident-looking answer.
A snapshot therefore states what is known and nothing more:
getBounds()is empty when the adapter published no safe geometry, never a zero rectangle.isVisibilityKnown()separates "reported hidden" from "not reported", andisVisible()is false in both cases.getActions()preserves slot order, including empty slots, because an action's position is part of its identity.getCapturedTick()andgetSnapshotGeneration()let a caller reject a stale observation before acting on it.
Snapshots are observational. Performing an action requires the capability-backed facade, which revalidates identity on the client thread immediately before dispatch.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intUpper bound on retained action slots; a longer list is malformed.static final intUpper bound on retained text; a longer value is malformed.static final intSentinel for a widget that is not a dynamic child.static final intSentinel for a widget whose revision-pinned sprite metadata is absent. -
Constructor Summary
ConstructorsConstructorDescriptionWidgetSnapshot(int packedId, int childIndex, String text, List<String> actions, boolean visible, boolean visibilityKnown, WidgetBounds bounds, int spriteId, long capturedTick, long snapshotGeneration) Creates a validated snapshot with optional revision-pinned sprite metadata.WidgetSnapshot(int packedId, int childIndex, String text, List<String> actions, boolean visible, boolean visibilityKnown, WidgetBounds bounds, long capturedTick, long snapshotGeneration) Creates a validated snapshot. -
Method Summary
Modifier and TypeMethodDescriptionbooleanfindExactAction(String action) Finds the single slot whose action equals a label, ignoring case.Returns the ordered action slots.Returns published geometry.longReturns the native tick this observation belongs to.intReturns the child identifier within the group.intReturns the dynamic child index.intReturns the widget group.intgetId()Returns the packedgroupId << 16 | childIdidentifier.longReturns the monotonic snapshot/session generation.Returns revision-pinned sprite metadata when the live widget exposes it.getText()Returns captured text, possibly blank.inthashCode()booleanTests full-text equality, ignoring case and surrounding whitespace.booleanhasUniqueExactAction(String exactAction) Tests direct, case-sensitive equality and requires one live action slot.booleanisCurrent(long generation) Tests whether this observation still belongs to a generation.booleanReturns whether this observation is a dynamic child.booleanReturns whether visibility was reported at all.booleanReturns whether the adapter reported this widget visible.toString()
-
Field Details
-
MAX_ACTIONS
public static final int MAX_ACTIONSUpper bound on retained action slots; a longer list is malformed.- See Also:
-
MAX_TEXT_LENGTH
public static final int MAX_TEXT_LENGTHUpper bound on retained text; a longer value is malformed.- See Also:
-
NO_CHILD_INDEX
public static final int NO_CHILD_INDEXSentinel for a widget that is not a dynamic child.- See Also:
-
NO_SPRITE_ID
public static final int NO_SPRITE_IDSentinel for a widget whose revision-pinned sprite metadata is absent.- See Also:
-
-
Constructor Details
-
WidgetSnapshot
public WidgetSnapshot(int packedId, int childIndex, String text, List<String> actions, boolean visible, boolean visibilityKnown, WidgetBounds bounds, long capturedTick, long snapshotGeneration) Creates a validated snapshot.- Parameters:
packedId- non-negativegroupId << 16 | childIdchildIndex- dynamic child index, orNO_CHILD_INDEXtext- captured text, possibly blank; nevernullactions- ordered action slots; blank entries preserve positionvisible- whether the adapter reported the widget visiblevisibilityKnown- whether the adapter reported visibility at allbounds- published geometry, ornullwhen unknowncapturedTick- native tick the observation belongs tosnapshotGeneration- monotonic snapshot/session generation- Throws:
IllegalArgumentException- for malformed identity, text, or actions
-
WidgetSnapshot
public WidgetSnapshot(int packedId, int childIndex, String text, List<String> actions, boolean visible, boolean visibilityKnown, WidgetBounds bounds, int spriteId, long capturedTick, long snapshotGeneration) Creates a validated snapshot with optional revision-pinned sprite metadata. A sprite is discovery information only; it is never an action identity.- Parameters:
spriteId- native sprite id, orNO_SPRITE_IDwhen absent
-
-
Method Details
-
getId
public int getId()Returns the packedgroupId << 16 | childIdidentifier.- Specified by:
getIdin interfaceIdentifiable- Returns:
- the packed
groupId << 16 | childIdidentifier
-
getGroupId
public int getGroupId()Returns the widget group.- Returns:
- the widget group
-
getChildId
public int getChildId()Returns the child identifier within the group.- Returns:
- the child identifier within the group
-
getChildIndex
public int getChildIndex()Returns the dynamic child index.- Returns:
- the dynamic child index, or
NO_CHILD_INDEXwhen this is a top-level component rather than a dynamic child
-
isDynamicChild
public boolean isDynamicChild()Returns whether this observation is a dynamic child.- Returns:
- whether this observation is a dynamic child
-
getText
Returns captured text, possibly blank.- Returns:
- captured text, possibly blank
-
getActions
Returns the ordered action slots.Empty strings mark slots the widget publishes without an action. Position is preserved because a slot's index is part of the contract the client uses to dispatch.
- Returns:
- immutable ordered action slots
-
getSpriteId
Returns revision-pinned sprite metadata when the live widget exposes it. This value cannot authorize interaction by itself. -
hasUniqueExactAction
Tests direct, case-sensitive equality and requires one live action slot. The generic action bridge deliberately does not trim, normalize, or choose among repeated labels. -
findExactAction
Finds the single slot whose action equals a label, ignoring case.- Parameters:
action- exact action label- Returns:
- the matching slot index, or empty when absent or ambiguous
-
isVisible
public boolean isVisible()Returns whether the adapter reported this widget visible.- Returns:
- whether the adapter reported this widget visible
-
isVisibilityKnown
public boolean isVisibilityKnown()Returns whether visibility was reported at all.isVisible()isfalseboth for a widget reported hidden and for one whose visibility the adapter never published. Use this to tell the two apart before treating absence as evidence.- Returns:
truewhen the adapter published a visibility flag
-
getBounds
Returns published geometry.- Returns:
- validated native-surface bounds, or empty when the adapter published none
-
getCapturedTick
public long getCapturedTick()Returns the native tick this observation belongs to.- Returns:
- the native tick this observation belongs to
-
getSnapshotGeneration
public long getSnapshotGeneration()Returns the monotonic snapshot/session generation.- Returns:
- the monotonic snapshot/session generation
-
isCurrent
public boolean isCurrent(long generation) Tests whether this observation still belongs to a generation.- Parameters:
generation- the caller's current snapshot generation- Returns:
truewhen the snapshot is from that same generation
-
hasText
Tests full-text equality, ignoring case and surrounding whitespace.- Parameters:
expected- expected text- Returns:
truewhen the captured text matches
-
equals
-
hashCode
public int hashCode() -
toString
-