Class NostrFilter

All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
Nip01UserMetadataFilter, NostrSearchFilter

public class NostrFilter extends NostrMessageFragment implements Cloneable
  • Constructor Details

    • NostrFilter

      public NostrFilter()
    • NostrFilter

      public NostrFilter(Map<String,Object> map)
  • Method Details

    • clone

      public NostrFilter clone()
      Overrides:
      clone in class Object
    • withId

      public NostrFilter withId(String id)
    • getIds

      public List<String> getIds()
    • withAuthor

      public NostrFilter withAuthor(String author)
    • withAuthor

      public NostrFilter withAuthor(NostrPublicKey author)
    • getAuthors

      public List<String> getAuthors()
    • withKind

      public NostrFilter withKind(int kind)
    • getKinds

      public List<Integer> getKinds()
    • since

      public NostrFilter since(Instant since)
    • getSince

      public Instant getSince()
    • getUntil

      public Instant getUntil()
    • until

      public NostrFilter until(Instant until)
    • limit

      public NostrFilter limit(int limit)
    • getLimit

      public Integer getLimit()
    • withTag

      public NostrFilter withTag(String key, String... values)
    • getTags

      public Map<String, List<String>> getTags()
    • getTagValues

      public List<String> getTagValues(String key)
    • toMap

      protected Map<String,Object> toMap()
      Specified by:
      toMap in class NostrMessageFragment
    • matches

      public boolean matches(SignedNostrEvent event)
      Checks if the given event matches this filter according to NIP-01 specs
      Parameters:
      event - the event to check
      Returns:
      true if the event matches the filter, false otherwise
    • matches

      public boolean matches(SignedNostrEvent event, boolean anyTagValue)
      Checks if the given event matches this filter
      Parameters:
      event - the event to check
      anyTagValue - if true, the filter will match if any of the tag values matches, otherwise it will only match if the first tag value matches (default nostr behavior per nip-01 spec).
      Returns:
    • matches

      public boolean matches(SignedNostrEvent event, int count)
      Checks if the given event matches this filter according to NIP-01 specs
      Parameters:
      event - the event to check
      count - the number of events already matched by this filter (used for limit)
      Returns:
      true if the event matches the filter, false otherwise
    • matches

      public boolean matches(SignedNostrEvent event, int count, boolean anyTagValue)
      Checks if the given event matches this filter
      Parameters:
      event - the event to check
      count - the number of events already matched by this filter (used for limit)
      anyTagValue - if true, the filter will match if any of the tag values matches, otherwise it will only match if the first tag value matches (default nostr behavior per nip-01 spec).
      Returns:
      true if the event matches the filter, false otherwise