Package groovy.transform.builder

# Class SimpleStrategy

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

All Implemented Interfaces:
  `BuilderASTTransformation.BuilderStrategy`

    public class SimpleStrategy
    extends BuilderASTTransformation.AbstractBuilderStrategy

This strategy is used with the `Builder` AST transform to modify your Groovy objects so that the setter methods for properties return the original object, thus allowing chained usage of the setters. You use it as follows:

     import groovy.transform.builder.*

     @Builder(builderStrategy=SimpleStrategy)
     class Person {
         String firstName
         String lastName
         int age
     }
     def person = new Person().setFirstName("Robert").setLastName("Lewandowski").setAge(21)
     assert person.firstName == "Robert"
     assert person.lastName == "Lewandowski"
     assert person.age == 21

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

     def p1 = new Person().firstName("Robert").lastName("Lewandowski").age(21)

or using a prefix of 'with':

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

When using the default prefix of "set", Groovy's normal setters will be replaced by the chained versions. When using a custom prefix, Groovy's unchained setters will still be available for use in the normal unchained fashion. The 'useSetters' annotation attribute can be used for writable properties as per the `Builder` transform documentation. The other annotation attributes for the `@Builder` transform for configuring the building process aren't applicable for this strategy.

- ## Nested Class Summary

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

  `BuilderASTTransformation.AbstractBuilderStrategy.PropertyInfo`

- ## Constructor Summary

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

- ## Method Summary

  Modifier and Type | Method | Description
  --- | --- | ---
  `void` | `build​(BuilderASTTransformation transform, AnnotatedNode annotatedNode, AnnotationNode anno)` |
  `protected java.util.List<FieldNode>` | `getFields​(BuilderASTTransformation transform, AnnotationNode anno, ClassNode buildee)` |

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

  `checkKnownField, checkKnownProperty, 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

  - ### SimpleStrategy

    public SimpleStrategy()

- ## Method Details

  - ### build

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

  - ### getFields

    protected java.util.List<FieldNode> getFields​(BuilderASTTransformation transform, AnnotationNode anno, ClassNode buildee)
    Overrides:
      `getFields` in class `BuilderASTTransformation.AbstractBuilderStrategy`