public class BuilderGenerationHelper extends ClassGenerationHelper
You should consider to use a builder when you are faced with many constructor
parameters. Specially mandatory and optional parameters. Here comes the
BuilderGenerationHelper
into play.
http://my.safaribooksonline.com/9780137150021/ch02lev1sec2
Constructor and Description |
---|
BuilderGenerationHelper(Writer sourceWriter) |
Modifier and Type | Method and Description |
---|---|
protected void |
generateBuilderBuildMethod(String builderObjectSimpleClassName)
Helper method to create the Builder#build() method which returns a concrete object instance.
|
void |
generateBuilderClass(String builderObjectSimpleClassName,
Collection<VariableElement> requiredFields,
Collection<VariableElement> optionalFields,
String... interfaces) |
protected void |
generateBuilderFieldAssignment(VariableElement fieldElement,
Object value) |
protected void |
generateBuilderHeader() |
protected void |
generateBuilderInvocationMethod(VariableElement fieldElement) |
void |
generateCustomBuilderConstructor(String customClassName,
Collection<VariableElement> fieldsToBePassedAndAssigned)
Creates a private object constructor which should only ever be called by the intern Builder class.
|
generateClassHeader, generateConstructorUsingFields, generateEmptyConstructor, generateEquals, generateFieldAccessors, generateFieldAssignment, generateHashCode, generateToString
close, determineFinalConstantValue, determineWrapperClass, firstCharToUpperCase, generateAnnotation, generateConstantFieldDeclaration, generateFieldDeclaration, generateFieldDeclaration, generateFieldDeclarations, generateFieldList, generateFooter, generateImports, generateImports, generateModifierList, generatePackageDeclaration, implode, isConstant, isFinal, isPrimitive, isStatic, manufactureAccessorName, manufactureField, manufactureIndentation, manufactureSetterName, manufactureSetterName, print, print, println, println, println, printWithoutSpaces, replaceParameters, resetWhitespaces, setWhitespaces
public BuilderGenerationHelper(Writer sourceWriter)
public void generateBuilderClass(String builderObjectSimpleClassName, Collection<VariableElement> requiredFields, Collection<VariableElement> optionalFields, String... interfaces)
public void generateCustomBuilderConstructor(String customClassName, Collection<VariableElement> fieldsToBePassedAndAssigned)
customClassName
- the object class namefieldsToBePassedAndAssigned
- the fieldsprotected void generateBuilderBuildMethod(String builderObjectSimpleClassName)
builderObjectSimpleClassName
- the object class nameprotected void generateBuilderFieldAssignment(VariableElement fieldElement, Object value)
fieldElement
- value
- protected void generateBuilderHeader()
protected void generateBuilderInvocationMethod(VariableElement fieldElement)
Copyright © 2010–2014 Arcbees. All rights reserved.