Class ExpectationEntry

java.lang.Object
org.mockserver.state.ExpectationEntry
All Implemented Interfaces:
Serializable

public final class ExpectationEntry extends Object implements Serializable
Serializable entry stored in the expectation KeyValueStore. Contains the Expectation definition plus the three sort fields (priority, created, id) that determine matching order. The live HttpRequestMatcher is NOT part of this entry — each node builds it lazily and caches it node-locally.

Implements Serializable with custom serialization: the Expectation is serialized as its JSON string (via Jackson ObjectMapper and ExpectationDTO) because the Expectation domain model classes do not implement Serializable. This keeps the wire format safe and avoids requiring Serializable on the entire domain graph.

See Also:
  • Constructor Details

    • ExpectationEntry

      public ExpectationEntry(Expectation expectation)
    • ExpectationEntry

      public ExpectationEntry(ExpectationEntry source, int remainingTimes)
      Copy constructor for CAS updates: creates a new entry with an updated remainingTimes counter while preserving all other fields. The expectation reference is shared (not cloned) because the entry is only used for the backend CAS swap; node-local matchers hold their own copy.
      Parameters:
      source - the source entry to copy from
      remainingTimes - the new remaining-times value
  • Method Details

    • getExpectation

      public Expectation getExpectation()
    • getPriority

      public int getPriority()
    • getCreated

      public long getCreated()
    • getId

      public String getId()
    • getRemainingTimes

      public int getRemainingTimes()
      Returns the shared remaining-times counter. -1 indicates unlimited Times (no CAS needed). 0 or positive indicates the number of remaining matches available for consumption across the cluster.
    • isTimesUnlimited

      public boolean isTimesUnlimited()
      Returns whether this entry's expectation has unlimited Times. Equivalent to getRemainingTimes() == -1.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object