Class InterfaceSpecImpl.BuilderImpl
- All Implemented Interfaces:
TypeSpec.Builder
- Enclosing class:
InterfaceSpecImpl
TypeSpec.Builder
for an interface.- Author:
- Square,Inc.
- Modified by:
- Thomas Thrien (thomas.thrien@tquadrat.org)
- Version:
- $Id: InterfaceSpecImpl.java 1064 2023-09-26 20:16:12Z tquadrat $
- Since:
- 0.2.0
- UML Diagram
-
UML Diagram for "org.tquadrat.foundation.javacomposer.internal.InterfaceSpecImpl.BuilderImpl"
-
Constructor Summary
ConstructorsConstructorDescriptionBuilderImpl(JavaComposer composer, CharSequence name) Creates a newBuilderImplinstance.BuilderImpl(JavaComposer composer, Optional<String> name) Creates a newBuilderImplinstance. -
Method Summary
Modifier and TypeMethodDescriptionaddAttribute(FieldSpec fieldSpec, boolean readOnly) Adds an attribute to this type.Adds a field to this type.addInitializerBlock(CodeBlock block) Adds code to the initializer block.addMethod(MethodSpec methodSpec) Adds a method for the type.final TypeSpec.BuilderaddProperty(FieldSpec fieldSpec, boolean readOnly) Adds a JavaBean property to this type.final InterfaceSpecImplbuild()Builds a newTypeSpecinstance from the added components.superclass(TypeName superclass) Sets the superclass for the type.Methods inherited from class org.tquadrat.foundation.javacomposer.internal.TypeSpecImpl.BuilderImpl
addAnnotation, addAnnotation, addAnnotation, addAnnotations, addEnumConstant, addEnumConstant, addEnumConstant, addEnumConstant, addField, addField, addFields, addJavadoc, addJavadoc, addMethods, addModifiers, addOriginatingElement, addStaticBlock, addStaticImport, addStaticImport, addStaticImport, addSuperinterface, addSuperinterface, addSuperinterface, addSuperinterface, addSuperinterfaces, addSuppressableWarning, addType, addTypes, addTypeVariable, addTypeVariable, addTypeVariables, composer, getAnnotations, getAnonymousTypeArguments, getEnumConstants, getFactory, getFieldSpecs, getInitializerBlock, getJavadoc, getMethodSpecs, getModifiers, getName, getStaticBlock, getStaticImports, getSuperclass, getSuperinterfaces, getTypeSpecs, getTypeVariables, isAnonymousClass, superclass
-
Constructor Details
-
BuilderImpl
Creates a newBuilderImplinstance.- Parameters:
composer- The reference to the factory that created this builder instance.name- The name of the type to build.
-
BuilderImpl
Creates a newBuilderImplinstance.- Parameters:
composer- The reference to the factory that created this builder instance.name- The name of the type to build.
-
-
Method Details
-
addAttribute
@API(status=STABLE, since="0.2.0") public final InterfaceSpecImpl.BuilderImpl addAttribute(FieldSpec fieldSpec, boolean readOnly) Adds an attribute to this type.
An attribute is basically a field with the related accessor and mutator methods.
If the name for a non-final property will be
text, and its type isjava.lang.String, the generated code will look basically like this:… private String m_Text; … public final String text() { return m_Text; } … public final void text( final String value ) { m_Text = text; } …If accessor or mutator needs to be more complex, the respective methods must be created manually.
- Specified by:
addAttributein interfaceTypeSpec.Builder- Specified by:
addAttributein classTypeSpecImpl.BuilderImpl- Parameters:
fieldSpec- The field definition.readOnly-trueif no mutator should be created even for a non-final field,falseif a mutator has to be created for a non-final field. Will ignored if the field is final.- Returns:
- This
Builderinstance.
-
addField
Adds a field to this type.- Specified by:
addFieldin interfaceTypeSpec.Builder- Overrides:
addFieldin classTypeSpecImpl.BuilderImpl- Parameters:
fieldSpec- The field definition.- Returns:
- This
Builderinstance.
-
addInitializerBlock
Adds code to the initializer block.- Specified by:
addInitializerBlockin interfaceTypeSpec.Builder- Overrides:
addInitializerBlockin classTypeSpecImpl.BuilderImpl- Parameters:
block- The code.- Returns:
- This
Builderinstance.
-
addMethod
Adds a method for the type.- Specified by:
addMethodin interfaceTypeSpec.Builder- Specified by:
addMethodin classTypeSpecImpl.BuilderImpl- Parameters:
methodSpec- The method.- Returns:
- This
Builderinstance.
-
addProperty
Adds a JavaBean property to this type.
A property is basically a field with the related getter and setter methods.
If the name for a non-final property will be
text, and its type isjava.lang.String, the generated code will look basically like this:… private String m_Text; … public final String getText() { return m_Text; } … public final void setText( final String value ) { m_Text = text; } …If getter or setter needs to be more complex, the respective methods must be created manually.
- Specified by:
addPropertyin interfaceTypeSpec.Builder- Specified by:
addPropertyin classTypeSpecImpl.BuilderImpl- Parameters:
fieldSpec- The field definition.readOnly-trueif no setter should be created even for a non-final field,falseif a setter has to be created for a non-final field. Will ignored if the field is final.- Returns:
- This
Builderinstance.
-
build
Builds a newTypeSpecinstance from the added components.- Specified by:
buildin interfaceTypeSpec.Builder- Specified by:
buildin classTypeSpecImpl.BuilderImpl- Returns:
- The new
TypeSpecinstance.
-
superclass
Sets the superclass for the type. This class is extended by the new type.
- Specified by:
superclassin interfaceTypeSpec.Builder- Overrides:
superclassin classTypeSpecImpl.BuilderImpl- Parameters:
superclass- The superclass.- Returns:
- This
Builderinstance.
-
