Package groovy.transform.builder

# Class ExternalStrategy

java.lang.Object
org.codehaus.groovy.transform.BuilderASTTransformation.AbstractBuilderStrategy
groovy.transform.builder.ExternalStrategy

All Implemented Interfaces:
  `BuilderASTTransformation.BuilderStrategy`

    public class ExternalStrategy
    extends BuilderASTTransformation.AbstractBuilderStrategy

This strategy is used with the `Builder` AST transform to populate a builder helper class so that it can be used for the fluent creation of instances of a specified class. The specified class is not modified in any way and may be a Java class. You use it by creating and annotating an explicit builder class which will be filled in by during annotation processing with the appropriate build method and setters. An example is shown here:

     import groovy.transform.builder.*

     class Person {
         String firstName
         String lastName
     }

     @Builder(builderStrategy=ExternalStrategy, forClass=Person)
     class PersonBuilder { }

     def person = new PersonBuilder().firstName("Robert").lastName("Lewandowski").build()
     assert person.firstName == "Robert"
     assert person.lastName == "Lewandowski"

The `prefix` annotation attribute, which defaults to the empty String for this strategy, can be used to create setters with a different naming convention, e.g. with the `prefix` changed to 'set', you would use your setters as follows:

     def p1 = new PersonBuilder().setFirstName("Robert").setLastName("Lewandowski").setAge(21).build()

or using a prefix of 'with':

     def p2 = new PersonBuilder().withFirstName("Robert").withLastName("Lewandowski").withAge(21).build()

The properties to use can be filtered using either the 'includes' or 'excludes' annotation attributes for `@Builder`. The `@Builder` 'buildMethodName' annotation attribute can be used for configuring the build method's name, default "build". The `@Builder` 'builderMethodName' and 'builderClassName' annotation attributes aren't applicable for this strategy. The `@Builder` 'useSetters' annotation attribute is ignored by this strategy which always uses setters.

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from class org.codehaus.groovy.transform.BuilderASTTransformation.AbstractBuilderStrategy

  `BuilderASTTransformation.AbstractBuilderStrategy.PropertyInfo`

- ## Constructor Summary

  Constructors
  Constructor | Description
  --- | ---
  `ExternalStrategy()` |

- ## Method Summary

  Modifier and Type | Method | Description
  --- | --- | ---
  `void` | `build​(BuilderASTTransformation transform, AnnotatedNode annotatedNode, AnnotationNode anno)` |

  ### Methods inherited from class org.codehaus.groovy.transform.BuilderASTTransformation.AbstractBuilderStrategy

  `checkKnownField, checkKnownProperty, getFields, getIncludeExclude, getPropertyInfoFromBeanInfo, getPropertyInfoFromClassNode, getPropertyInfoFromClassNode, getPropertyInfoFromClassNode, getPropertyInfos, getSetterName, unsupportedAttribute, unsupportedAttribute`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### ExternalStrategy

    public ExternalStrategy()

- ## Method Details

  - ### build

    public void build​(BuilderASTTransformation transform, AnnotatedNode annotatedNode, AnnotationNode anno)