Top Description Fields Constructors Methods
org.newsclub.net.unix

public Class CloseablePair<T extends Closeable>

extends Object
implements Closeable
Class Inheritance
All Implemented Interfaces
java.io.Closeable, java.lang.AutoCloseable
Known Direct Subclasses
org.newsclub.net.unix.AFSocketPair
Type Parameters
<T>
The type of the items.
Imports
java.io.Closeable, .IOException, java.util.Objects, org.eclipse.jdt.annotation.NonNull

A pair of two closeable items.
Author
Christian Kohlschütter

Field Summary

Modifier and TypeField and Description
private final Closeable
private final @NonNull T
private final @NonNull T

Constructor Summary

AccessConstructor and Description
public
CloseablePair(T
The first item.
a
,
T
The second item.
b
)

Creates a pair of two items.

public
CloseablePair(T
The first item.
a
,
T
The second item.
b
,
Closeable
Some closeable that is also closed upon close(), or null.
alsoClose
)

Creates a pair of two items.

Method Summary

Modifier and TypeMethod and Description
public final void
close()

Implements java.io.Closeable.close.

Closes this stream and releases any system resources associated with it.

public final @NonNull T

Returns:

The first item.
getFirst
()

Returns the pair's first item.

public final @NonNull T

Returns:

The second item.
getSecond
()

Returns the pair's second item.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

alsoCloseback to summary
private final Closeable alsoClose
firstback to summary
private final @NonNull T first
secondback to summary
private final @NonNull T second

Constructor Detail

CloseablePairback to summary
public CloseablePair(T a, T b)

Creates a pair of two items.

Parameters
a:T

The first item.

b:T

The second item.

CloseablePairback to summary
public CloseablePair(T a, T b, Closeable alsoClose)

Creates a pair of two items.

Parameters
a:T

The first item.

b:T

The second item.

alsoClose:Closeable

Some closeable that is also closed upon close(), or null.

Method Detail

closeback to summary
public final void close() throws IOException

Implements java.io.Closeable.close.

Doc from java.io.Closeable.close.

Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.

As noted in AutoCloseable#close(), cases where the close may fail require careful attention. It is strongly advised to relinquish the underlying resources and to internally mark the Closeable as closed, prior to throwing the IOException.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
getFirstback to summary
public final @NonNull T getFirst()

Returns the pair's first item.

Returns:@NonNull T

The first item.

getSecondback to summary
public final @NonNull T getSecond()

Returns the pair's second item.

Returns:@NonNull T

The second item.