net.sf.molae.pipe.union
Class ObjectUnion<B,T1 extends B,T2 extends B>

java.lang.Object
  extended by net.sf.molae.pipe.basic.ObjectProxy<B>
      extended by net.sf.molae.pipe.union.ObjectUnion<B,T1,T2>
Direct Known Subclasses:
Extendable

public class ObjectUnion<B,T1 extends B,T2 extends B>
extends ObjectProxy<B>

An instance of a union of type T1 or type T2, of which neither is a superclass of the other. The base type of a union is the most specific class that is a supertype of both, T1 and T2. The union implements the methods of the supertype. ObjectUnion implements the union with base type Object.

Since:
2.0

Constructor Summary
protected ObjectUnion(T1 base)
          Creates an object union of type 1 with the given value.
protected ObjectUnion(T2 base, boolean dummy)
          Creates an object union of type 2 with the given value.
 
Method Summary
 T1 getBase1()
          Allows a type safe get of the base value.
 T2 getBase2()
          Allows a type safe get of the base value.
 boolean isOfType1()
          Gives information about the base type of this union.
static
<B,T1 extends B,T2 extends B>
ObjectUnion<B,T1,T2>
newInstance1(T1 base)
          Constructs an ObjectUnion of type T1.
static
<B,T1 extends B,T2 extends B>
ObjectUnion<B,T1,T2>
newInstance2(T2 base)
          Constructs an ObjectUnion of type T2.
 
Methods inherited from class net.sf.molae.pipe.basic.ObjectProxy
assertNotNull, equals, getBase, hashCode, toString, toVerboseString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ObjectUnion

protected ObjectUnion(T1 base)
Creates an object union of type 1 with the given value.

Parameters:
base - value of this object union

ObjectUnion

protected ObjectUnion(T2 base,
                      boolean dummy)
Creates an object union of type 2 with the given value.

Parameters:
base - value of this object union
dummy - is ignored
Method Detail

newInstance1

public static <B,T1 extends B,T2 extends B> ObjectUnion<B,T1,T2> newInstance1(T1 base)
Constructs an ObjectUnion of type T1.

Parameters:
base - value of this instance

newInstance2

public static <B,T1 extends B,T2 extends B> ObjectUnion<B,T1,T2> newInstance2(T2 base)
Constructs an ObjectUnion of type T2.

Parameters:
base - value of this instance

isOfType1

public boolean isOfType1()
Gives information about the base type of this union.

Returns:
true if the base value is of type T1

getBase1

public T1 getBase1()
Allows a type safe get of the base value.

Returns:
the base value of this union
Throws:
ClassCastException - base value is not of T1

getBase2

public T2 getBase2()
Allows a type safe get of the base value.

Returns:
the base value of this union
Throws:
ClassCastException - base value is not of T2