rcf.core.util.groups
Class Singleton<A>

java.lang.Object
  extended by rcf.core.util.groups.Singleton<A>
All Implemented Interfaces:
ImmutableSingletonInterface<A>, SingletonInterface<A>
Direct Known Subclasses:
GUIImmutableCollection, GUIImmutableTree, Pair, StrongReference

@Revision(value="$Revision: 1.29 $",
          date="$Date: 2006/11/09 02:10:10 $",
          tag="$Name:  $")
public class Singleton<A>
extends Object
implements SingletonInterface<A>

TODO: Javadoc Provides a simple, type safe (generic) wrapper which can encapsulate a single reference. Alone this class is pratically useless, as it provides no benefit above a simple reference. However in conjunction with the rcf.core.util.collection.position package or the Pair class, this class provides a vital base.

Version:
$Revision: 1.29 $
Author:
Greg Gibeling

Nested Class Summary
static class Singleton.Iterable<A>
          TODO: Javadoc Wrap a single iterable collection, create an iterable over singletons of elements.
static class Singleton.Iterator<A>
          TODO: Javadoc Wrap a single iterator, create an iterator over singletons of elements.
 
Field Summary
protected  A a
          TODO: Javadoc The content element to store.
 
Constructor Summary
Singleton(A _a)
          TODO: Javadoc Base constructor, simply records the content element for this object.
 
Method Summary
static
<A> Singleton<A>[]
composeArrays(A[] a)
          TODO: Javadoc Compose an array of values into an array of singletons.
static
<A,S extends ImmutableSingletonInterface<A>>
A[]
decomposeArrays(S[] s)
          TODO: Javadoc Decompose an array of singletons into an array of values.
 boolean equals(Object o)
           
 A get()
          TODO: Javadoc Get the content element of this singleton.
 int hashCode()
           
 A set(A _a)
          TODO: Javadoc Set the content element of this singleton.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

a

protected A a
TODO: Javadoc The content element to store.

Constructor Detail

Singleton

public Singleton(A _a)
TODO: Javadoc Base constructor, simply records the content element for this object.

Parameters:
_a - The content element to store.
Method Detail

composeArrays

public static final <A> Singleton<A>[] composeArrays(A[] a)
TODO: Javadoc Compose an array of values into an array of singletons.

Type Parameters:
A - The type of the elements in the array, and the content element in each singleton.
Parameters:
a - Array of the content elements of the resulting singletons.
Returns:
An array of singletons of values pulled from the specified array.

decomposeArrays

public static final <A,S extends ImmutableSingletonInterface<A>> A[] decomposeArrays(S[] s)
TODO: Javadoc Decompose an array of singletons into an array of values.

Type Parameters:
A - The type of the elements in the array, and the content element in each singleton.
S - The type of the actual elements in the input array. Must extend ImmutableSingletonInterface.
Parameters:
s - An array of singletons of values to be put into the resulting array.
Returns:
Array of the content elements of the specified singletons.

equals

public boolean equals(Object o)
Overrides:
equals in class Object

get

public A get()
Description copied from interface: ImmutableSingletonInterface
TODO: Javadoc Get the content element of this singleton.

Specified by:
get in interface ImmutableSingletonInterface<A>
Returns:
The content element of this singleton.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

set

public A set(A _a)
Description copied from interface: SingletonInterface
TODO: Javadoc Set the content element of this singleton.

Specified by:
set in interface SingletonInterface<A>
Parameters:
_a - The new content element of this singleton.
Returns:
The old content element of this singleton.

toString

public String toString()
Overrides:
toString in class Object