Class StubGuard

java.lang.Object
com.botwithus.bot.api.diag.StubGuard

public final class StubGuard extends Object
Warns once per method-name when a producer-side stub is invoked.

Producer-backed API surface (entity queries that depend on producer-side iteration the C++ side hasn't shipped yet) typically returns an empty list without telling the caller. StubGuard closes that gap: the first time warnOnce(String) is called for a given method name the configured sink fires; subsequent calls for the same name are suppressed.

The warned set is an instance field (per-StubGuard rather than process-global) — callers that want independent throttling just hold independent instances.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Default sink — logs at WARN to the StubGuard logger.
    Custom sink — receives the method name on first call only.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    warnOnce(String methodName)
    Fires the sink the first time methodName is observed; suppresses subsequent calls for the same name.

    Methods inherited from class Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • StubGuard

      public StubGuard()
      Default sink — logs at WARN to the StubGuard logger. Useful for production wiring where the warning should appear in normal log output.
    • StubGuard

      public StubGuard(Consumer<String> sink)
      Custom sink — receives the method name on first call only. Useful for tests (collect into a List) or for integration with an event bus.
  • Method Details

    • warnOnce

      public void warnOnce(String methodName)
      Fires the sink the first time methodName is observed; suppresses subsequent calls for the same name. Thread-safe.