net.sf.staccatocommons.lang.builder
Class AbstractReusableBuilder<T>

java.lang.Object
  extended by net.sf.staccatocommons.lang.builder.AbstractReusableBuilder<T>
Type Parameters:
T - the kind of object this AbstractReusableBuilder can create
All Implemented Interfaces:
Builder<T>, ReusableBuilder<T>

public abstract class AbstractReusableBuilder<T>
extends Object
implements ReusableBuilder<T>

An abstract implementation of a builder pattern. Guarantees the following aspects of a builder

Client code has two responsibilities:

Author:
flbulgarelli

Nested Class Summary
static class AbstractReusableBuilder.DoneCheck
          A Check that throws an ObjectUnderConstructionException when checks fail
 
Constructor Summary
AbstractReusableBuilder()
           
 
Method Summary
 T build()
          Checks the builder is ready for creating a new object, sending checkDone(DoneCheck) messages, and then creates it, sending buildObject().
protected abstract  T buildObject()
           
protected  void checkDone(AbstractReusableBuilder.DoneCheck check)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractReusableBuilder

public AbstractReusableBuilder()
Method Detail

build

public final T build()
              throws ObjectUnderConstructionException
Checks the builder is ready for creating a new object, sending checkDone(DoneCheck) messages, and then creates it, sending buildObject().

Specified by:
build in interface Builder<T>
Specified by:
build in interface ReusableBuilder<T>
Returns:
The built object.
Throws:
ObjectUnderConstructionException - as defined in Builder
See Also:
ReusableBuilder.build()

checkDone

protected void checkDone(AbstractReusableBuilder.DoneCheck check)
                  throws ObjectUnderConstructionException
Throws:
ObjectUnderConstructionException

buildObject

protected abstract T buildObject()

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2010-2012 Staccatocommons. All Rights Reserved.