java.lang.Object
gnu.java.util.EmptyEnumeration
- All Implemented Interfaces:
- java.util.Enumeration, java.io.Serializable
- public final class EmptyEnumeration
- extends java.lang.Object
- implements java.util.Enumeration, java.io.Serializable
This is a helper class that produces an empty Enumerations. There is only
one instance of this class that can be used whenever one needs a
non-null but empty enumeration. Using this class prevents multiple
small objects and inner classes. getInstance() returns
the only instance of this class. It can be shared by multiple objects and
threads.
|
Constructor Summary |
private |
EmptyEnumeration()
Private constructor that creates a new empty Enumeration. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
instance
private static final EmptyEnumeration instance
- The only instance of this class
EmptyEnumeration
private EmptyEnumeration()
- Private constructor that creates a new empty Enumeration.
getInstance
public static EmptyEnumeration getInstance()
- Returns the only instance of this class.
It can be shared by multiple objects and threads.
hasMoreElements
public boolean hasMoreElements()
- Returns false, since there are no elements.
- Specified by:
hasMoreElements in interface java.util.Enumeration
nextElement
public java.lang.Object nextElement()
- Always throws
NoSuchElementException, since it is empty.
- Specified by:
nextElement in interface java.util.Enumeration