Record Class HttpClientOwnership

java.lang.Object
java.lang.Record
ca.cdr.test.app.clients.common.HttpClientOwnership
Record Components:
client - the client to issue requests on
owned - true in the owned case, so closeIfOwned() closes client

public record HttpClientOwnership(@Nonnull SmileTestHttpClient client, boolean owned) extends Record
The HTTP client a test client issues on, and whether closing that test client should close the HTTP client with it. There are two cases, decided by resolve(SmileTestHttpClient):
  • Borrowed ? the caller supplied a SmileTestHttpClient, typically a harness lending one client to everything it hands out. The connection pool and cookie store stay the supplier's, so closing the test client must leave them up for the siblings still using them.
  • Owned ? the caller supplied null, so a client was built here. Nothing else holds a reference, so closing the test client is the only thing that can release the pool.
  • Constructor Summary

    Constructors
    Constructor
    Description
    HttpClientOwnership(SmileTestHttpClient client, boolean owned)
    Creates an instance of a HttpClientOwnership record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the value of the client record component.
    void
    Releases the connection pool when this client built it, and does nothing when the pool was supplied by a caller that still needs it.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    boolean
    Returns the value of the owned record component.
    resolve(SmileTestHttpClient theSuppliedClient)
    Decides which of the two cases applies for a client built with theSuppliedClient, building a client when the caller supplied none.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • HttpClientOwnership

      public HttpClientOwnership(@Nonnull SmileTestHttpClient client, boolean owned)
      Creates an instance of a HttpClientOwnership record class.
      Parameters:
      client - the value for the client record component
      owned - the value for the owned record component
  • Method Details

    • resolve

      @Nonnull public static HttpClientOwnership resolve(@Nullable SmileTestHttpClient theSuppliedClient)
      Decides which of the two cases applies for a client built with theSuppliedClient, building a client when the caller supplied none.
      Parameters:
      theSuppliedClient - the client the caller supplied, or null to build one
    • closeIfOwned

      public void closeIfOwned()
      Releases the connection pool when this client built it, and does nothing when the pool was supplied by a caller that still needs it.
    • 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.
    • client

      @Nonnull public SmileTestHttpClient client()
      Returns the value of the client record component.
      Returns:
      the value of the client record component
    • owned

      public boolean owned()
      Returns the value of the owned record component.
      Returns:
      the value of the owned record component