Record Class AuditQuery

java.lang.Object
java.lang.Record
com.svenruppert.jsentinel.audit.AuditQuery
Record Components:
types - restrict to these AuditEvent subtypes, or empty to allow every type
subjectId - restrict to events whose subjectId equals this value, or null to ignore the subject
from - restrict to events with timestampfrom, or null for no lower bound
to - restrict to events with timestampto, or null for no upper bound
limit - maximum number of results, or 0 for unlimited

public record AuditQuery(Set<Class<? extends AuditEvent>> types, String subjectId, Instant from, Instant to, int limit) extends Record
Filter passed to JSentinelAuditService.query(...). All fields are optional — a all() query returns every retained event.

Filters compose with AND semantics: an event must match every non-empty predicate to be included.

  • Constructor Details

    • AuditQuery

      public AuditQuery(Set<Class<? extends AuditEvent>> types, String subjectId, Instant from, Instant to, int limit)
      Creates an instance of a AuditQuery record class.
      Parameters:
      types - the value for the types record component
      subjectId - the value for the subjectId record component
      from - the value for the from record component
      to - the value for the to record component
      limit - the value for the limit record component
  • Method Details

    • all

      public static AuditQuery all()
      A query that returns every retained event.
    • ofType

      public static AuditQuery ofType(Class<? extends AuditEvent> type)
      A query restricted to a single event type.
      Parameters:
      type - the AuditEvent subtype to filter on
      Returns:
      query matching only events of type
    • forSubject

      public static AuditQuery forSubject(String subjectId)
      A query restricted to a single subject.
      Parameters:
      subjectId - the subject id to filter on
      Returns:
      query matching only events carrying subjectId
    • matches

      public boolean matches(AuditEvent event)
      Parameters:
      event - the event to test against this query's predicates
      Returns:
      true if the event matches every active predicate
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • types

      public Set<Class<? extends AuditEvent>> types()
      Returns the value of the types record component.
      Returns:
      the value of the types record component
    • subjectId

      public String subjectId()
      Returns the value of the subjectId record component.
      Returns:
      the value of the subjectId record component
    • from

      public Instant from()
      Returns the value of the from record component.
      Returns:
      the value of the from record component
    • to

      public Instant to()
      Returns the value of the to record component.
      Returns:
      the value of the to record component
    • limit

      public int limit()
      Returns the value of the limit record component.
      Returns:
      the value of the limit record component