Skip to content
master
Switch branches/tags
Code

Latest commit

You can use `@AutoBuilder` to call an `@AutoAnnotation` method. As usual for `@AutoAnnotation`, each parameter of that method corresponds to an element of the annotation. If that element has a default value, the parameter should default to that same value.

Trivial example:
```java
class Example {
  @interface MyAnnotation {
    String value() default "foo";
  }

  @AutoAnnotation
  static MyAnnotation myAnnotation(String value) {
    return new AutoAnnotation_Example_myAnnotation(value);
  }

  @autobuilder(callMethod = "myAnnotation")
  interface MyAnnotationBuilder {
    MyAnnotationBuilder value(String value);
    MyAnnotation build();
  }

  static MyAnnotationBuilder myAnnotationBuilder() {
    return new AutoBuilder_Example_MyAnnotationBuilder();
  }
}
```

In the example, the call `myAnnotationBuilder().build()` has the same effect as `myAnnotationBuilder().value("foo").build()` because of `value() default "foo"`.

RELNOTES=AutoBuilder now uses annotation defaults when building a call to an `@AutoAnnotation` method.
PiperOrigin-RevId: 395114215
fb96c83

Git stats

Files

Permalink
Failed to load latest commit information.

Auto

Build Status

A collection of source code generators for Java.

Auto‽

Java is full of code that is mechanical, repetitive, typically untested and sometimes the source of subtle bugs. Sounds like a job for robots!

The Auto subprojects are a collection of code generators that automate those types of tasks. They create the code you would have written, but without the bugs.

Save time. Save code. Save sanity.

Subprojects

License

Copyright 2013 Google LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.