Nested classes are used to reduce the size of the global namespace,
to minimize cyclic dependencies, and to clarify dependency
relationships.
A nested class is like an inner class except that it is declared
'static'. Unlike an inner class, a nested class does not have an
implicit reference to the object that created it.
Here are some examples of where nested classes are preferred over
package-scope classes:
- Exception types thrown by a single class.
- Factory interfaces. Nesting a factory interface eliminates a
cyclic dependency between a type and its factory interface.
- Implementation classes used by a single class.
- Class bundles, like the gov.va.med.term.access.criteria.Criteria
class. A class bundle allows a client to acquire a cohesive set of
classes in one import, and prevents name collisions with other classes
by requiring names to be scoped.