java.io.Serializable, java.lang.Cloneablepublic abstract class Union2<First,Second>
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable
Object.equals(java.lang.Object) and Object.hashCode() treat this as a container,
not identical to the contained object, but the identity is based on the contained
object. The union is serialiable if its contained object is.
Object.toString() delegates to the contained object.| Modifier and Type | Method | Description |
|---|---|---|
abstract Union2<First,Second> |
clone() |
|
static <First,Second> |
createFirst(First first) |
Construct a union based on the first type.
|
static <First,Second> |
createSecond(Second second) |
Construct a union based on the second type.
|
abstract First |
first() |
Retrieve the union member of the first type.
|
abstract boolean |
hasFirst() |
Check if the union contains the first type.
|
abstract boolean |
hasSecond() |
Check if the union contains the second type.
|
abstract Second |
second() |
Retrieve the union member of the second type.
|
public abstract First first() throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException - if the union really contains the second typepublic abstract Second second() throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException - if the union really contains the first typepublic abstract boolean hasFirst()
public abstract boolean hasSecond()
public static <First,Second> Union2<First,Second> createFirst(First first)
first - an object of the first typepublic static <First,Second> Union2<First,Second> createSecond(Second second)
second - an object of the second typeBuilt on April 24 2018. | Portions Copyright 1997-2018 Oracle. All rights reserved.