Class PredicateBuilder<K,V>

java.lang.Object
com.loomcache.server.query.PredicateBuilder<K,V>
Type Parameters:
K - the map key type
V - the map value type
All Implemented Interfaces:
MapPredicate<K,V>

public final class PredicateBuilder<K,V> extends Object implements MapPredicate<K,V>
Fluent predicate builder for distributed map queries.

Mirrors Hazelcast's PredicateBuilder shape:

PredicateBuilder.EntryObject<String, Employee> e =
    Predicates.<String, Employee>newPredicateBuilder().getEntryObject();
MapPredicate<String, Employee> predicate =
    e.is("active").and(e.get("age").lessThan(30));

Each terminal PredicateBuilder.EntryObject operation returns a new immutable builder predicate, so the same entry object can be reused safely while composing predicates.

  • Constructor Details

  • Method Details

    • getAttribute

      public String getAttribute()
      Returns the last attribute represented by this builder.
      Returns:
      the selected attribute path
    • setAttribute

      public void setAttribute(String attribute)
      Updates the attribute metadata exposed for Hazelcast-compatible callers.
      Parameters:
      attribute - attribute path
    • getEntryObject

      public PredicateBuilder.EntryObject<K,V> getEntryObject()
      Returns the entry object used to select key/value attributes and create terminal predicates.
      Returns:
      a reusable entry object
    • and

      public PredicateBuilder<K,V> and(MapPredicate<K,V> other)
      Composes this predicate with another using logical AND.
      Parameters:
      other - predicate to combine with
      Returns:
      a new builder wrapping the composed predicate
    • or

      public PredicateBuilder<K,V> or(MapPredicate<K,V> other)
      Composes this predicate with another using logical OR.
      Parameters:
      other - predicate to combine with
      Returns:
      a new builder wrapping the composed predicate
    • test

      public boolean test(K key, V value)
      Description copied from interface: MapPredicate
      Tests whether the given map entry matches this predicate.
      Specified by:
      test in interface MapPredicate<K,V>
      Parameters:
      key - the entry key (non-null)
      value - the entry value (non-null)
      Returns:
      true if the entry matches, false otherwise
    • toString

      public String toString()
      Overrides:
      toString in class Object