Evaluating Software Design Patterns
— the "Gang of Four" patterns implemented in Java 6

dk.rode.thesis.meta.reflect
Class CallerClass.CallerIterator<C extends CallerClass>

java.lang.Object
  extended by dk.rode.thesis.meta.reflect.CallerClass.CallerIterator<C>
Type Parameters:
C - The specific (sub-) type of the caller class to iterate over.
All Implemented Interfaces:
Iterator<C>
Enclosing class:
CallerClass

protected abstract static class CallerClass.CallerIterator<C extends CallerClass>
extends Object
implements Iterator<C>

A caller iterator is used to iterator over CallerClass instances, or sub-classes of it.

Implementation notes:
This is an application of the Iterator pattern specialised for sub-classes of CallerClass. The setNext() method can on a fine day be considered an application of the Factory Method pattern.

Author:
Gunni Rode / rode.dk

Field Summary
protected  C caller
          The current caller set by setNext().
 
Constructor Summary
CallerClass.CallerIterator(C caller)
          Constructor.
 
Method Summary
 boolean hasNext()
          Returns true if additional callers are in the call-stack, false if not.
 C next()
          Returns the next caller.
 void remove()
          Always throws an UnsupportedOperationException.
(package private) abstract  void setNext()
          Sets the next caller class, or sub-class or it, to be retrieved by the next call to next().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

caller

protected C extends CallerClass caller
The current caller set by setNext().

Never null.

Constructor Detail

CallerClass.CallerIterator

CallerClass.CallerIterator(C caller)
Constructor.

Parameters:
caller - The caller to start from; can be null.
Method Detail

hasNext

public boolean hasNext()
Returns true if additional callers are in the call-stack, false if not.

Specified by:
hasNext in interface Iterator<C extends CallerClass>
Returns:
True if more callers, false if not.

next

public C next()
Returns the next caller.

Specified by:
next in interface Iterator<C extends CallerClass>
Returns:
The next caller; never null.

remove

public void remove()
Always throws an UnsupportedOperationException.

Specified by:
remove in interface Iterator<C extends CallerClass>
Throws:
UnsupportedOperationException - Always thrown.

setNext

abstract void setNext()
Sets the next caller class, or sub-class or it, to be retrieved by the next call to next().


Gunni Rode / rode.dk

Feel free to use and/or modify the Java 6 source code developed for this thesis AT YOUR OWN RISK, but note that the source code comes WITHOUT ANY — and I do mean WITHOUT ANY — form of warranty WHAT SO EVER!

The original thesis and source code are available at rode.dk/thesis.