Class PropertyCodeGenerator
- java.lang.Object
-
- org.inferred.freebuilder.processor.property.PropertyCodeGenerator
-
- Direct Known Subclasses:
BiMapProperty,BuildableListProperty,BuildableProperty,DefaultProperty,ListMultimapProperty,ListProperty,MapProperty,MultisetProperty,NullableProperty,OptionalProperty,PrimitiveOptionalProperty,SetMultimapProperty,SetProperty,SortedSetProperty
public abstract class PropertyCodeGenerator extends java.lang.ObjectProperty-type-specific code generation interface.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfacePropertyCodeGenerator.ConfigData available toPropertyCodeGenerator.Factoryinstances when creating aPropertyCodeGenerator.static interfacePropertyCodeGenerator.FactoryFactory interface forPropertyCodeGenerator.static classPropertyCodeGenerator.InitiallyGeneral behaviour type for a fresh or reset property.
-
Constructor Summary
Constructors Constructor Description PropertyCodeGenerator(Datatype datatype, Property property)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddAccessorAnnotations(SourceBuilder code)abstract voidaddAssignToBuilder(SourceBuilder code, Variable builder)Adds an assignment to the field on the builder from the Value/Partial implementation.abstract voidaddBuilderFieldAccessors(SourceBuilder code)Add the accessor methods for the property to the builder's source code.abstract voidaddBuilderFieldDeclaration(SourceBuilder code)Add the field declaration for the property to the builder's source code.abstract voidaddClearField(SourceBuilder code)Adds a clear call for the property given a template builder to the builder's source code.private voidaddFieldValues(java.lang.Class<?> cls, com.google.common.collect.ImmutableMap.Builder<java.lang.String,java.lang.Object> valuesBuilder)abstract voidaddFinalFieldAssignment(SourceBuilder code, Excerpt finalField, java.lang.String builder)Add the final assignment of the property to the value object's source code.voidaddGetterAnnotations(SourceBuilder code)Adds method annotations for the value type getter method.abstract voidaddMergeFromBuilder(SourceBuilder code, java.lang.String builder)Add a merge from builder for the property to the builder's source code.abstract voidaddMergeFromValue(SourceBuilder code, java.lang.String value)Add a merge from value for the property to the builder's source code.voidaddPartialFieldAssignment(SourceBuilder code, Excerpt finalField, java.lang.String builder)Add the final assignment of the property to the partial value object's source code.voidaddPutAnnotations(SourceBuilder code)voidaddReadValueFragment(SourceBuilder code, Excerpt finalField)Adds a fragment converting the value object's field to the property's type.abstract voidaddSetFromResult(SourceBuilder code, Excerpt builder, Excerpt variable)Adds a set call for the property from a function result to the builder's source code.voidaddToStringCondition(SourceBuilder code)Adds condition statement for an initially optional property to be included in the toString output for the Value/Partial types.voidaddToStringValue(SourceBuilder code)Adds value to an ongoing toString concatenation or append sequence.abstract voidaddValueFieldDeclaration(SourceBuilder code)Add the field declaration for the property to the value's source code.booleanequals(java.lang.Object obj)private java.util.Map<java.lang.String,java.lang.Object>fieldValues()abstract java.util.Set<MergeAction>getMergeActions()Returns the actions taken in mergeFrom, for generating JavaDoc.inthashCode()PropertyCodeGenerator.InitiallyinitialState()Returns whether the property is required, optional, or has a default.java.lang.StringtoString()
-
-
-
Method Detail
-
initialState
public PropertyCodeGenerator.Initially initialState()
Returns whether the property is required, optional, or has a default.
-
addValueFieldDeclaration
public abstract void addValueFieldDeclaration(SourceBuilder code)
Add the field declaration for the property to the value's source code.
-
addBuilderFieldDeclaration
public abstract void addBuilderFieldDeclaration(SourceBuilder code)
Add the field declaration for the property to the builder's source code.
-
addBuilderFieldAccessors
public abstract void addBuilderFieldAccessors(SourceBuilder code)
Add the accessor methods for the property to the builder's source code.
-
addFinalFieldAssignment
public abstract void addFinalFieldAssignment(SourceBuilder code, Excerpt finalField, java.lang.String builder)
Add the final assignment of the property to the value object's source code.
-
addPartialFieldAssignment
public void addPartialFieldAssignment(SourceBuilder code, Excerpt finalField, java.lang.String builder)
Add the final assignment of the property to the partial value object's source code.
-
addAssignToBuilder
public abstract void addAssignToBuilder(SourceBuilder code, Variable builder)
Adds an assignment to the field on the builder from the Value/Partial implementation.
-
addMergeFromValue
public abstract void addMergeFromValue(SourceBuilder code, java.lang.String value)
Add a merge from value for the property to the builder's source code.
-
addMergeFromBuilder
public abstract void addMergeFromBuilder(SourceBuilder code, java.lang.String builder)
Add a merge from builder for the property to the builder's source code.
-
getMergeActions
public abstract java.util.Set<MergeAction> getMergeActions()
Returns the actions taken in mergeFrom, for generating JavaDoc.
-
addGetterAnnotations
public void addGetterAnnotations(SourceBuilder code)
Adds method annotations for the value type getter method.
-
addReadValueFragment
public void addReadValueFragment(SourceBuilder code, Excerpt finalField)
Adds a fragment converting the value object's field to the property's type.
-
addSetFromResult
public abstract void addSetFromResult(SourceBuilder code, Excerpt builder, Excerpt variable)
Adds a set call for the property from a function result to the builder's source code.
-
addClearField
public abstract void addClearField(SourceBuilder code)
Adds a clear call for the property given a template builder to the builder's source code.
-
addToStringCondition
public void addToStringCondition(SourceBuilder code)
Adds condition statement for an initially optional property to be included in the toString output for the Value/Partial types.- Throws:
java.lang.IllegalStateException- ifinitialState()is notPropertyCodeGenerator.Initially.OPTIONAL
-
addToStringValue
public void addToStringValue(SourceBuilder code)
Adds value to an ongoing toString concatenation or append sequence.
-
addAccessorAnnotations
public void addAccessorAnnotations(SourceBuilder code)
-
addPutAnnotations
public void addPutAnnotations(SourceBuilder code)
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
fieldValues
private java.util.Map<java.lang.String,java.lang.Object> fieldValues()
-
addFieldValues
private void addFieldValues(java.lang.Class<?> cls, com.google.common.collect.ImmutableMap.Builder<java.lang.String,java.lang.Object> valuesBuilder)
-
-