Interface Singleton

All Known Implementing Classes:
EnumInfoBuilder, EnumSourceBuilder, Operations, Operations.Add

public interface Singleton

Classes that implement this interface are Singletons. The class must hold a static instance of the class named IT. Generally, IT should be public, final and initialized by an static call to a constructor. The class should have a private final constructor. The class should also override toString() to return some information about the internal state of IT. Often, the class should be final.

If the Singleton is also Serializable and stateless, it should override readResolve() to return IT, like this: private Object readResolve() throws ObjectStreamException { return IT; } If the Singleton isn't stateless, you'll need to make decisions about keeping the current state of the singleton or replacing the existing state when deserializing.

David Walend

Copyright (c) 2001, 2002, David Walend