JML

org.jmlspecs.jmlunit.strategies
Class CachedObjectAbstractStrategy

java.lang.Object
  extended byorg.jmlspecs.jmlunit.strategies.CachedObjectAbstractStrategy
All Implemented Interfaces:
StrategyType
Direct Known Subclasses:
CloneableObjectAbstractStrategy, ImmutableObjectAbstractStrategy

public abstract class CachedObjectAbstractStrategy
extends Object
implements StrategyType

A strategy for producing (test) data of an immutable or cloneable reference types from cached data provided by the user. The data used is cached, and thus only has to be produced once.

By default, null is the only test data provided, but this means that subclasses don't have to provide null as data, unless they override the defaultData() method.

This type also provides an extension mechanism that is easier to use than a composite, wherein subclasses of subclasses can override the addData() method to provide additional data for testing.

Author:
Gary T. Leavens

Field Summary
private  Object[] data
          The data to return in the iterations
 
Constructor Summary
CachedObjectAbstractStrategy()
           
 
Method Summary
protected  Object[] addData()
          Subclasses can override this to make simple extensions to the data used.
protected  Object[] defaultData()
          Create and return the default data for the iterations.
protected  Object[] getData()
          Create and return the data for the iterations.
 IndefiniteIterator iterator()
          Compute a fresh indefinite iterator, which can be used to provide test data of some reference type.
protected abstract  IndefiniteIterator iteratorFor(Object[] data)
          Return an appropriate iterator for the data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

data

private Object[] data
The data to return in the iterations

Constructor Detail

CachedObjectAbstractStrategy

public CachedObjectAbstractStrategy()
Method Detail

iterator

public IndefiniteIterator iterator()
Description copied from interface: StrategyType
Compute a fresh indefinite iterator, which can be used to provide test data of some reference type. The indefinite iterator returned should be freshly created. Usually it should not be at its end. However, in rare cases it might make sense to have an empty iterator be computed (e.g., by filtering).

Specified by:
iterator in interface StrategyType

iteratorFor

protected abstract IndefiniteIterator iteratorFor(Object[] data)
Return an appropriate iterator for the data.


getData

protected Object[] getData()
Create and return the data for the iterations. This is should only be called once for this object.


defaultData

protected Object[] defaultData()
Create and return the default data for the iterations. This is should only be called once for this object.


addData

protected Object[] addData()
Subclasses can override this to make simple extensions to the data used.


JML

JML is Copyright (C) 1998-2002 by Iowa State University and is distributed under the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This release depends on code from the MultiJava project and is based in part on the Kopi project Copyright (C) 1990-99 DMS Decision Management Systems Ges.m.b.H.