Class ActivityQuery

java.lang.Object
dyntabs.ai.activity.ActivityQuery

public final class ActivityQuery extends Object
An immutable description of which slice of the activity timeline you want back from an ActivityStore — a small set of filters (session, tab, age, category) plus a cap on how many of the most recent matches to return.

What this class is for

The activity timeline can hold many entries, but a prompt only wants the handful that matter right now: usually "the last few things this user did in this tab". An ActivityQuery is how you say that precisely — scope it to a sessionId() and tabId(), optionally only keep events

invalid reference
newer than
some moment or of certain types, and cap the count. The store does the filtering and hands back a chronological list.

Familiar analogy: a search filter on an email client — "from this folder, this label, newer than yesterday, show 20". You aren't fetching the whole mailbox; you're asking for exactly the visible, relevant window. ActivityQuery is that filter for the activity log.

Filter semantics

  • A null sessionId() or tabId() means "don't filter on that field" (match any). A non-null value must match exactly.
  • since() keeps only events at or after that instant; null means no lower bound.
  • types() keeps only events whose UserActivityEvent.Type is in the set; an empty set means all types.
  • limit() keeps only the N most recent matches (a value <= 0 means "no limit").
See Also:
  • Method Details

    • sessionId

      public String sessionId()
      Returns:
      the session to match exactly, or null to match any session.
    • tabId

      public String tabId()
      Returns:
      the tab to match exactly, or null to match any tab.
    • since

      public Instant since()
      Returns:
      the lower time bound (inclusive), or null for no lower bound.
    • types

      public Set<UserActivityEvent.Type> types()
      Returns:
      an unmodifiable set of accepted types; empty means "all types". Never null.
    • limit

      public int limit()
      Returns:
      the maximum number of most-recent matches to return; <= 0 means no limit.
    • matches

      public boolean matches(UserActivityEvent e)
      Test whether a single event satisfies this query's field filters.

      Note this deliberately does not apply limit() — the limit is about how many matches to keep, which only makes sense over a collection. A store calls this per event to decide membership, then applies the limit to the surviving set.

      Parameters:
      e - the event to test; must not be null
      Returns:
      true if the event passes every field filter
    • builder

      public static ActivityQuery.Builder builder()
      Returns:
      a new, empty ActivityQuery.Builder.
    • toString

      public String toString()
      Overrides:
      toString in class Object