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

dk.rode.thesis.bridge
Class Main

java.lang.Object
  extended by dk.rode.thesis.bridge.Main
All Implemented Interfaces:
Testable

public class Main
extends Object
implements Testable

Bridge tests.

Author:
Gunni Rode / rode.dk

Constructor Summary
Main()
          No-arg constructor.
 
Method Summary
private static
<E> boolean
create(Log out, Map<MemorizableSequence<E>,SequenceMemento<E>> mementos, MemorizableSequence<E> sequence)
          Creates a new memento acquired from sequence.
private static
<E> Map<MemorizableSequence<E>,SequenceMemento<E>>
createMap()
          Creates a new map to store (memorizable sequence, memento) pairs.
private static boolean equals(Object a, Object b)
          Test for equality including support for proxies.
static void main(String[] args)
          Executes the Bridge tests.
 boolean test(Log out, Arguments arguments)
          Performs the specific tests and report the outcome to the log supplied as log.
private static
<E> boolean
use(Log out, Map<MemorizableSequence<E>,SequenceMemento<E>> mementos, MemorizableSequence<E> sequence)
          Updates sequence using the relevant memento stored in mementos.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Main

public Main()
No-arg constructor.

Method Detail

create

private static final <E> boolean create(Log out,
                                        Map<MemorizableSequence<E>,SequenceMemento<E>> mementos,
                                        MemorizableSequence<E> sequence)
Creates a new memento acquired from sequence.

Type Parameters:
E - The type of values delivered by sequence.
Parameters:
out - The log to use; never null.
mementos - The map to store the created memento; never null.
sequence - The sequence to create the memento; never null.
Returns:
True upon success, false if not.

createMap

private static final <E> Map<MemorizableSequence<E>,SequenceMemento<E>> createMap()
Creates a new map to store (memorizable sequence, memento) pairs.

Type Parameters:
E - The type of values delivered by applicable sequences.
Returns:
A new map to use; never null.

equals

private static final boolean equals(Object a,
                                    Object b)
Test for equality including support for proxies.

Parameters:
a - The first object; cannot be null.
b - The second object; cannot be null.
Returns:
True if equal, false if not.

main

public static void main(String[] args)
                 throws Exception
Executes the Bridge tests.

Parameters:
args - The arguments to supply to test(Log, Arguments), if any; can be null.
Throws:
Exception - If the test fails unexpectedly.

test

public boolean test(Log out,
                    Arguments arguments)
             throws Exception
Description copied from interface: Testable
Performs the specific tests and report the outcome to the log supplied as log.

Arguments to control log-level:

Specified by:
test in interface Testable
Parameters:
out - The log to report the test outcome to; cannot be null.
arguments - Additional arguments, if any.
Returns:
True if the tests succeeded, false if not.
Throws:
NullPointerException - If out is null.
Exception - In case an unexpected error occurs.

use

private static final <E> boolean use(Log out,
                                     Map<MemorizableSequence<E>,SequenceMemento<E>> mementos,
                                     MemorizableSequence<E> sequence)
Updates sequence using the relevant memento stored in mementos.

Type Parameters:
E - The type of values delivered by sequence.
Parameters:
out - The log to use; never null.
mementos - The map to storing the created memento; never null.
sequence - The sequence to be updated; never null.
Returns:
True upon success, false if not.

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.