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

dk.rode.thesis.bridge
Class SequenceValueLinkedHashSet<E extends Serializable>

java.lang.Object
  extended by dk.rode.thesis.bridge.SequenceValueCollection<E,C>
      extended by dk.rode.thesis.bridge.SequenceValueSet<E,LinkedHashSet<E>>
          extended by dk.rode.thesis.bridge.SequenceValueLinkedHashSet<E>
Type Parameters:
E - The type of serializable values stored in this value set.
All Implemented Interfaces:
SequenceValueGenerator<E>, Copyable<SequenceValueGenerator<E>>, Stringable<SequenceValueGenerator<E>>

@Participant(value="ConcreteImplementor")
public class SequenceValueLinkedHashSet<E extends Serializable>
extends SequenceValueSet<E,LinkedHashSet<E>>

A sequence value linked hash set stores sequence values in a java.util.LinkedHashSet instance.

A sequence value linked hash set is always ordered, unsorted, and contains no duplicates.

Author:
Gunni Rode / rode.dk

Field Summary
 
Fields inherited from class dk.rode.thesis.bridge.SequenceValueCollection
number, type, values
 
Constructor Summary
  SequenceValueLinkedHashSet(Class<E> type, LinkedHashSet<E> values)
          Constructor, which creates this sequence value linked hash set to use the LinkedHashSet instance supplied as values.
private SequenceValueLinkedHashSet(Class<E> type, LinkedHashSet<E> values, int number)
          Constructor, which creates this sequence value linked hash set to use the LinkedHashSet instance supplied as values.
 
Method Summary
 SequenceValueLinkedHashSet<E> copy()
          Performs a deep copy of this generator.
 boolean ordered()
          Returns true.
 boolean sorted()
          Returns false.
 
Methods inherited from class dk.rode.thesis.bridge.SequenceValueSet
duplicates, first, get, get, numberOf
 
Methods inherited from class dk.rode.thesis.bridge.SequenceValueCollection
checkNumber, equals, getStringablePolicy, getValueType, hashCode, number, size, toCollection, toString, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SequenceValueLinkedHashSet

public SequenceValueLinkedHashSet(Class<E> type,
                                  LinkedHashSet<E> values)
Constructor, which creates this sequence value linked hash set to use the LinkedHashSet instance supplied as values.

Modifying values externally will affect this value set and should not be performed. The result of doing so is undefined - but never good.

Parameters:
type - The type of values stored in this value set (and values); cannot be null.
values - The actual LinkedHashSet instance storing the sequence values; cannot be null, empty, or contain null values.
Throws:
NullPointerException - If either argument is null.
IllegalArgumentException - If values is empty, contain a null value.

SequenceValueLinkedHashSet

private SequenceValueLinkedHashSet(Class<E> type,
                                   LinkedHashSet<E> values,
                                   int number)
Constructor, which creates this sequence value linked hash set to use the LinkedHashSet instance supplied as values.

Modifying values externally will affect this value set and should not be performed. The result of doing so is undefined - but never good.

Parameters:
type - The type of values stored in this value set (and values); cannot be null.
values - The actual LinkedHashSet instance storing the sequence values; cannot be null, empty, or contain null values.
number - The number pointing the the number'th value to be returned by the next call to SequenceValueSet.get().
Throws:
NullPointerException - If either argument is null.
IllegalArgumentException - If values is empty, contain a null value, or if number is illegal.
Method Detail

copy

public SequenceValueLinkedHashSet<E> copy()
Description copied from class: SequenceValueCollection
Performs a deep copy of this generator.

The size, ordered, sorted, and duplicate properties are adhered to by the returned clone.

The work in copying this collection is proportional with the number of values contained, and is thus more expensive the larger this collection is!

Specified by:
copy in interface SequenceValueGenerator<E extends Serializable>
Specified by:
copy in interface Copyable<SequenceValueGenerator<E extends Serializable>>
Specified by:
copy in class SequenceValueCollection<E extends Serializable,LinkedHashSet<E extends Serializable>>
Returns:
A copy of this value collection; never null.

ordered

public boolean ordered()
Returns true.

Returns:
True.

sorted

public boolean sorted()
Returns false.

Returns:
False.

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.