Class CloseablePair<T extends Closeable>

java.lang.Object
org.newsclub.net.unix.CloseablePair<T>
Type Parameters:
T - The type of the items.
All Implemented Interfaces:
Closeable, AutoCloseable
Direct Known Subclasses:
AFSocketPair

public class CloseablePair<T extends Closeable> extends Object implements Closeable
A pair of two closeable items.
Author:
Christian Kohlschütter
  • Constructor Details

    • CloseablePair

      public CloseablePair(T a, T b)
      Creates a pair of two items.
      Parameters:
      a - The first item.
      b - The second item.
    • CloseablePair

      public CloseablePair(T a, T b, Closeable alsoClose)
      Creates a pair of two items.
      Parameters:
      a - The first item.
      b - The second item.
      alsoClose - Some closeable that is also closed upon close(), or null.
  • Method Details

    • close

      public final void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • getFirst

      public final @NonNull T getFirst()
      Returns the pair's first item.
      Returns:
      The first item.
    • getSecond

      public final @NonNull T getSecond()
      Returns the pair's second item.
      Returns:
      The second item.