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

dk.rode.thesis.builder
Class TypedComparableExpressionBuilder<E extends Comparable<? super E>>

java.lang.Object
  extended by dk.rode.thesis.builder.AbstractExpressionBuilder<E>
      extended by dk.rode.thesis.builder.TypedExpressionBuilder<E>
          extended by dk.rode.thesis.builder.TypedComparableExpressionBuilder<E>
Type Parameters:
E - The Comparable type of values the constructed expressions operate on and/or produces.
All Implemented Interfaces:
ComparableExpressionBuilder<E>, ExpressionBuilder<E>, Copyable<ExpressionBuilder<E>>, StrictCopyable<ExpressionBuilder<E>>

@Participant(value="ConcreteBuilder")
public class TypedComparableExpressionBuilder<E extends Comparable<? super E>>
extends TypedExpressionBuilder<E>
implements ComparableExpressionBuilder<E>

A typed comparable expression builder construct various TypedExpression types having a Comparable bound on the value produced by the constructed expressions and on the expression operands used.

Author:
Gunni Rode / rode.dk

Field Summary
 
Fields inherited from class dk.rode.thesis.builder.TypedExpressionBuilder
builder, type
 
Fields inherited from class dk.rode.thesis.builder.AbstractExpressionBuilder
context, root, sequence
 
Constructor Summary
TypedComparableExpressionBuilder(Class<E> type, ComparableExpressionBuilder<E> builder)
          Constructor.
TypedComparableExpressionBuilder(TypedComparableExpressionBuilder<E> builder)
          Copy constructor.
TypedComparableExpressionBuilder(TypedExpressionBuilder<E> builder)
          Copy constructor.
 
Method Summary
 TypedExpression<Boolean> buildGreaterThanExpression(Expression<E> first, Expression<E> second)
          Builds a new GREATER THAN expression.
 TypedExpression<E> buildSetExpression(Expression<E> value)
          Builds a new SET expression.
 TypedExpression<Boolean> buildSmallerThanExpression(Expression<E> first, Expression<E> second)
          Builds a new SMALLER THAN expression.
 TypedComparableExpressionBuilder<E> copy()
          Returns a deep copy of this object.
 
Methods inherited from class dk.rode.thesis.builder.TypedExpressionBuilder
buildAndExpression, buildAssignmentExpression, buildBreakExpression, buildConditionalExpression, buildCurrentExpression, buildEqualExpression, buildFlowExpression, buildInitialisedFlowExpression, buildNextExpression, buildNonShortCircuitAndExpression, buildNonShortCircuitOrExpression, buildNotExpression, buildOrExpression, buildResetExpression, buildReverseExpression, getTypedExpression, type
 
Methods inherited from class dk.rode.thesis.builder.AbstractExpressionBuilder
buildConstantExpression, buildExpression, buildVariableExpression, equals, getContext, getRootExpression, getSequence, hashCode, initialiseExpressions, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface dk.rode.thesis.builder.ExpressionBuilder
buildAndExpression, buildAssignmentExpression, buildBreakExpression, buildConditionalExpression, buildConstantExpression, buildCurrentExpression, buildEqualExpression, buildExpression, buildFlowExpression, buildInitialisedFlowExpression, buildNextExpression, buildNonShortCircuitAndExpression, buildNonShortCircuitOrExpression, buildNotExpression, buildOrExpression, buildResetExpression, buildReverseExpression, buildVariableExpression, getRootExpression, getSequence
 

Constructor Detail

TypedComparableExpressionBuilder

public TypedComparableExpressionBuilder(Class<E> type,
                                        ComparableExpressionBuilder<E> builder)
Constructor.

The same sequence as used by builder will be used by this builder, but a new local context will be created and used.

Parameters:
type - The class literal representing the type of value the evaluation of constructed expressions produces; cannot be null.
builder - The actual builder to use; cannot be null.
Throws:
NullPointerException - If either argument is null.

TypedComparableExpressionBuilder

public TypedComparableExpressionBuilder(TypedComparableExpressionBuilder<E> builder)
Copy constructor.

The same context and sequence as used by builder will be used by this builder.

The root expression from builder is not copied. Hence, this builder is ready to construct new expressions, and return a unique root expression from AbstractExpressionBuilder.getRootExpression().

Parameters:
builder - The builder to copy; cannot be null.
Throws:
NullPointerException - If builder is null.

TypedComparableExpressionBuilder

public TypedComparableExpressionBuilder(TypedExpressionBuilder<E> builder)
Copy constructor.

The same sequence as used by builder will be used by this builder, but a new local context will be created and used. The root expression from builder is not copied. Hence, this builder is ready to construct new expressions, and return a unique root expression from AbstractExpressionBuilder.getRootExpression().

Parameters:
builder - The builder to copy; cannot be null.
Throws:
NullPointerException - If builder is null.
Method Detail

buildGreaterThanExpression

public TypedExpression<Boolean> buildGreaterThanExpression(Expression<E> first,
                                                           Expression<E> second)
Description copied from interface: ComparableExpressionBuilder
Builds a new GREATER THAN expression.

Specified by:
buildGreaterThanExpression in interface ComparableExpressionBuilder<E extends Comparable<? super E>>
Parameters:
first - The first expression operand; cannot be null.
second - The second expression operand; cannot be null.
Returns:
The constructed expression; never null.

buildSetExpression

public TypedExpression<E> buildSetExpression(Expression<E> value)
Description copied from interface: ComparableExpressionBuilder
Builds a new SET expression.

Specified by:
buildSetExpression in interface ComparableExpressionBuilder<E extends Comparable<? super E>>
Parameters:
value - The expression that will determine the sequence value to fast-forward to for the sequence when the constructed expression is evaluated.
Returns:
The constructed expression; never null.

buildSmallerThanExpression

public TypedExpression<Boolean> buildSmallerThanExpression(Expression<E> first,
                                                           Expression<E> second)
Description copied from interface: ComparableExpressionBuilder
Builds a new SMALLER THAN expression.

Specified by:
buildSmallerThanExpression in interface ComparableExpressionBuilder<E extends Comparable<? super E>>
Parameters:
first - The first expression operand; cannot be null.
second - The second expression operand; cannot be null.
Returns:
The constructed expression; never null.

copy

public TypedComparableExpressionBuilder<E> copy()
Description copied from interface: Copyable
Returns a deep copy of this object.

Specified by:
copy in interface Copyable<ExpressionBuilder<E extends Comparable<? super E>>>
Overrides:
copy in class TypedExpressionBuilder<E extends Comparable<? super E>>
Returns:
The copy; 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.