net.sf.staccatocommons.lang.builder
Class AbstractReusableBuilder<T>
java.lang.Object
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
- Will not return the built object unless the construction process has
finished
- Will not permit the builder to be used more than once, this is, the built
object can not be retrieved more than once
Client code has two responsibilities:
- Add methods that actually configure the object under construction
- Implement
#checkDone(Check) to verify the object under
construction is actually done
- Author:
- flbulgarelli
AbstractReusableBuilder
public AbstractReusableBuilder()
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.