站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc (Current Development Version)

Union2 (Utilities API) - NetBeans API Javadoc (Current Development Version)

org.openide.util 7.9.0 1

org.openide.util
Class Union2<First,Second>

java.lang.Object
  extended by org.openide.util.Union2<First,Second>
All Implemented Interfaces:
Serializable, Cloneable

public abstract class Union2<First,Second>
extends Object
implements Cloneable, Serializable

A union type which can contain one of two kinds of objects. 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.

Since:
org.openide.util 7.1
See Also:
Serialized Form

Method Summary
abstract  Union2<First,Second> clone()
           
static
<First,Second>
Union2<First,Second>
createFirst(First first)
          Construct a union based on the first type.
static
<First,Second>
Union2<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.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

first

public abstract First first()
                     throws IllegalArgumentException
Retrieve the union member of the first type.

Returns:
the object of the first type
Throws:
IllegalArgumentException - if the union really contains the second type

second

public abstract Second second()
                       throws IllegalArgumentException
Retrieve the union member of the second type.

Returns:
the object of the second type
Throws:
IllegalArgumentException - if the union really contains the first type

hasFirst

public abstract boolean hasFirst()
Check if the union contains the first type.

Returns:
true if it contains the first type, false if it contains the second type

hasSecond

public abstract boolean hasSecond()
Check if the union contains the second type.

Returns:
true if it contains the second type, false if it contains the first type

clone

public abstract Union2<First,Second> clone()
Overrides:
clone in class Object

createFirst

public static <First,Second> Union2<First,Second> createFirst(First first)
Construct a union based on the first type.

Parameters:
first - an object of the first type
Returns:
a union containing that object

createSecond

public static <First,Second> Union2<First,Second> createSecond(Second second)
Construct a union based on the second type.

Parameters:
second - an object of the second type
Returns:
a union containing that object

org.openide.util 7.9.0 1

Built on May 28 2007.  |  Portions Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.