Interface SerializablePredicate

All Known Implementing Classes:
SerializablePredicate.All, SerializablePredicate.KeyEquals, SerializablePredicate.KeyStartsWith, SerializablePredicate.ValueContains, SerializablePredicate.ValueEquals

Wire-serializable predicate for MessageType.CQC_SUBSCRIBE.

A sealed hierarchy of lightweight predicates that can be shipped client -> server over the binary protocol. Both sides implement the same matching semantics against raw String map keys / values, so the server can evaluate the predicate locally to filter map change events and only push matched entries to the subscribing client.

Wire format

  [1-byte kind][kind-specific body]

  ALL                     => [0x01]
  KEY_EQUALS(s)           => [0x02][int len][utf8 bytes of s]
  VALUE_EQUALS(s)         => [0x03][int len][utf8 bytes of s]
  KEY_STARTS_WITH(s)      => [0x04][int len][utf8 bytes of s]
  VALUE_CONTAINS(s)       => [0x05][int len][utf8 bytes of s]

Rationale

Shipping a full SQL parser or BiPredicate<K,V> over the wire is out of scope for the initial CQC wire support. This minimal set covers the common continuous-query patterns (filter by key prefix, substring match, exact match) while keeping the encoding small, deterministic, and language-agnostic.
Since:
2.0
  • Field Details

  • Method Details

    • test

      boolean test(String key, @Nullable String value)
      Test whether the predicate matches the given entry.
      Parameters:
      key - the entry key (non-null — decoded map keys are always non-null)
      value - the entry value (may be null for REMOVED events)
      Returns:
      true if the entry matches
    • encode

      byte[] encode()
      Encode this predicate into a newly-allocated byte array.
    • all

      static SerializablePredicate all()
      Match every entry.
    • keyEquals

      static SerializablePredicate keyEquals(String value)
      Match entries whose key equals value.
    • valueEquals

      static SerializablePredicate valueEquals(String value)
      Match entries whose value equals value.
    • keyStartsWith

      static SerializablePredicate keyStartsWith(String prefix)
      Match entries whose key starts with prefix.
    • valueContains

      static SerializablePredicate valueContains(String substring)
      Match entries whose value contains substring.
    • decode

      static SerializablePredicate decode(byte[] bytes)
      Decode a predicate from wire bytes produced by encode().
      Parameters:
      bytes - the wire payload
      Returns:
      the decoded predicate
      Throws:
      IllegalArgumentException - if bytes is malformed, truncated, or exceeds size limits