net.walend.enum
Class AbstractEnum

java.lang.Object
  |
  +--net.walend.enum.AbstractEnum
All Implemented Interfaces:
java.util.Collection, Enum, Immutable, java.io.Serializable, java.util.Set
Direct Known Subclasses:
Operations

public abstract class AbstractEnum
extends java.lang.Object
implements Enum, java.io.Serializable

A utility class that implements all of Enum's methods by delegating them to an underlying immutable Set. Concrete subclasses should be singletons. They should override readResolve() to return the singleton value.

Since:
20021230
Author:
David Walend david@walend.net
See Also:
Serialized Form

Field Summary
private  java.util.Set set
           
 
Constructor Summary
protected AbstractEnum(java.util.Set memberSet)
           
 
Method Summary
 boolean add(java.lang.Object o)
          This method always throws an UnsupportedOperationException.
 boolean addAll(java.util.Collection c)
          This method always throws an UnsupportedOperationException.
 void clear()
          This method always throws an UnsupportedOperationException.
 boolean contains(java.lang.Object o)
           
 boolean containsAll(java.util.Collection c)
           
 boolean equals(java.lang.Object o)
           
 int hashCode()
           
 boolean isEmpty()
           
 java.util.Iterator iterator()
           
 boolean remove(java.lang.Object o)
          This method always throws an UnsupportedOperationException.
 boolean removeAll(java.util.Collection c)
          This method always throws an UnsupportedOperationException.
 boolean retainAll(java.util.Collection c)
          This method always throws an UnsupportedOperationException.
 int size()
           
 java.lang.Object[] toArray()
           
 java.lang.Object[] toArray(java.lang.Object[] a)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

set

private final java.util.Set set
Constructor Detail

AbstractEnum

protected AbstractEnum(java.util.Set memberSet)
Method Detail

size

public int size()
Specified by:
size in interface java.util.Set

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Set

contains

public boolean contains(java.lang.Object o)
Specified by:
contains in interface java.util.Set

iterator

public java.util.Iterator iterator()
Specified by:
iterator in interface java.util.Set

toArray

public java.lang.Object[] toArray()
Specified by:
toArray in interface java.util.Set

toArray

public java.lang.Object[] toArray(java.lang.Object[] a)
Specified by:
toArray in interface java.util.Set

add

public boolean add(java.lang.Object o)
This method always throws an UnsupportedOperationException.

Specified by:
add in interface java.util.Set
Throws:
java.lang.UnsupportedOperationException - because this is an immutable object.

remove

public boolean remove(java.lang.Object o)
This method always throws an UnsupportedOperationException.

Specified by:
remove in interface java.util.Set
Throws:
java.lang.UnsupportedOperationException - because this is an immutable object.

containsAll

public boolean containsAll(java.util.Collection c)
Specified by:
containsAll in interface java.util.Set

addAll

public boolean addAll(java.util.Collection c)
This method always throws an UnsupportedOperationException.

Specified by:
addAll in interface java.util.Set
Throws:
java.lang.UnsupportedOperationException - because this is an immutable object.

retainAll

public boolean retainAll(java.util.Collection c)
This method always throws an UnsupportedOperationException.

Specified by:
retainAll in interface java.util.Set
Throws:
java.lang.UnsupportedOperationException - because this is an immutable object.

removeAll

public boolean removeAll(java.util.Collection c)
This method always throws an UnsupportedOperationException.

Specified by:
removeAll in interface java.util.Set
Throws:
java.lang.UnsupportedOperationException - because this is an immutable object.

clear

public void clear()
This method always throws an UnsupportedOperationException.

Specified by:
clear in interface java.util.Set
Throws:
java.lang.UnsupportedOperationException - because this is an immutable object.

equals

public boolean equals(java.lang.Object o)
Specified by:
equals in interface java.util.Set
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Specified by:
hashCode in interface java.util.Set
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright (c) 2001, 2002, David Walend