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

dk.rode.thesis.abstractfactory
Class RangeValueFactory

java.lang.Object
  extended by dk.rode.thesis.abstractfactory.RangeValueFactory
All Implemented Interfaces:
GeneratorFactory<Integer,Integer[]>

@ParticipantUsage(value="ConcreteProduct",
                  type=SequenceValueRange.class)
@Participant(value="ConcreteFactory")
public class RangeValueFactory
extends Object
implements GeneratorFactory<Integer,Integer[]>

A range value factory creates value range generators.

This factory is thread-safe.

Author:
Gunni Rode / rode.dk

Field Summary
private  Integer[] defaultMinMax
          The default range for the created generators.
 
Constructor Summary
RangeValueFactory(int minimum)
          Constructor, which creates this factory to use the minimum value of minimum for all created generators.
RangeValueFactory(int minimum, int maximum)
          Constructor, which creates this factory to use the minimum value of minimum for all created generators.
 
Method Summary
 SequenceValueRange createGenerator()
          Creates a new sequence value generator using the default argument.
 SequenceValueRange createGenerator(Integer[] minMax)
          Creates a new sequence value generator, where argument is an argument used in the creation process of the generator.
 Integer[] getDefaultArgument()
          Returns the default argument to use for generator creation in case no argument is supplied to the GeneratorFactory.createGenerator(Object) method.
 String toString()
          Returns the string representation of this factory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

defaultMinMax

private final Integer[] defaultMinMax
The default range for the created generators.

Length = 1: minimum range, no upper value.

Length = 2: minimum and maximum.

Never null.

Constructor Detail

RangeValueFactory

public RangeValueFactory(int minimum)
Constructor, which creates this factory to use the minimum value of minimum for all created generators.

Parameters:
minimum - The minimum value.

RangeValueFactory

public RangeValueFactory(int minimum,
                         int maximum)
Constructor, which creates this factory to use the minimum value of minimum for all created generators.

Parameters:
minimum - The minimum value.
maximum - The maximum value.
Throws:
IllegalArgumentException - If minimum is larger than maximum.
Method Detail

createGenerator

public SequenceValueRange createGenerator()
Description copied from interface: GeneratorFactory
Creates a new sequence value generator using the default argument.

Specified by:
createGenerator in interface GeneratorFactory<Integer,Integer[]>
Returns:
A new created generator; never null.
See Also:
GeneratorFactory.createGenerator(Object), GeneratorFactory.getDefaultArgument()

createGenerator

public SequenceValueRange createGenerator(Integer[] minMax)
Description copied from interface: GeneratorFactory
Creates a new sequence value generator, where argument is an argument used in the creation process of the generator.

Specified by:
createGenerator in interface GeneratorFactory<Integer,Integer[]>
Parameters:
minMax - The range, where a length of one indicates a minimum only, and a length of two indicates a minimum and maximum value; can be null, in which case the default range is used.
Returns:
A new created generator; never null.
Throws:
IllegalArgumentException - If minimum is larger than maximum.
See Also:
GeneratorFactory.createGenerator()

getDefaultArgument

public Integer[] getDefaultArgument()
Description copied from interface: GeneratorFactory
Returns the default argument to use for generator creation in case no argument is supplied to the GeneratorFactory.createGenerator(Object) method.

Specified by:
getDefaultArgument in interface GeneratorFactory<Integer,Integer[]>
Returns:
The default argument, if any; can be null, depending on the actual implementation.

toString

public String toString()
Returns the string representation of this factory.

Overrides:
toString in class Object
Returns:
The string representation; never null.

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.