Record Class EgressCheckResult

java.lang.Object
java.lang.Record
com.agentforge4j.util.net.EgressCheckResult
Record Components:
allowed - whether the target is an eligible egress destination
reason - null when allowed() is true; otherwise a non-secret description of the classification (host and address detail, never a request body, header, or secret)

public record EgressCheckResult(boolean allowed, String reason) extends Record
Outcome of an OutboundEgressGuard classification of a target URL. This is a neutral, dependency-free classification result — it states whether the target resolves to an eligible (public) destination and, when not, a non-secret reason() describing why. It carries no policy verb and never throws; the caller decides how to react (fail a tool call, refuse a configuration, and so on).
  • Constructor Details

    • EgressCheckResult

      public EgressCheckResult(boolean allowed, String reason)
      Enforces the result invariants: an allowed result carries no (misleading) denial reason, and a denied result carries a non-blank reason. The reason being non-secret is a caller contract — the guard only ever supplies host/scheme classification detail — and cannot be machine-checked here.
      Throws:
      IllegalArgumentException - if allowed is true with a non-null reason, or false with a blank reason
  • Method Details

    • allow

      public static EgressCheckResult allow()
      Returns:
      an allowed result with no reason
    • deny

      public static EgressCheckResult deny(String reason)
      Parameters:
      reason - non-blank, non-secret description of why the target is not eligible
      Returns:
      a denied result carrying reason
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • allowed

      public boolean allowed()
      Returns the value of the allowed record component.
      Returns:
      the value of the allowed record component
    • reason

      public String reason()
      Returns the value of the reason record component.
      Returns:
      the value of the reason record component