Class Either<T,U>
java.lang.Object
org.opendaylight.yangtools.concepts.Either<T,U>
- Type Parameters:
T
- First alternative typeU
- Second alternative type
- All Implemented Interfaces:
Immutable
- Direct Known Subclasses:
CheckedValue
Utility holder of a two-variant value. The class design treats both variants as equal.
- Author:
- Robert Varga
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected MoreObjects.ToStringHelper
final boolean
protected final T
first()
final T
getFirst()
final U
final int
hashCode()
final boolean
isFirst()
final boolean
isSecond()
static <T,
U> Either<T, U> ofFirst
(T value) Create a new instance containing specified value.static <T,
U> Either<T, U> ofSecond
(U value) Create a new instance containing specified value.protected final U
second()
final String
toString()
tryFirst()
-
Constructor Details
-
Either
-
Either
-
-
Method Details
-
first
-
second
-
ofFirst
Create a new instance containing specified value.- Type Parameters:
T
- First alternative typeU
- Second alternative type- Parameters:
value
- Value- Returns:
- A new instance
- Throws:
NullPointerException
- ifvalue
is null
-
ofSecond
Create a new instance containing specified value.- Type Parameters:
T
- First alternative typeU
- Second alternative type- Parameters:
value
- Value- Returns:
- A new instance
- Throws:
NullPointerException
- ifvalue
is null
-
isFirst
public final boolean isFirst() -
getFirst
-
tryFirst
-
isSecond
public final boolean isSecond() -
getSecond
-
trySecond
-
hashCode
public final int hashCode() -
equals
-
toString
-
addToString
-