JavaFileObject build() {
      String nullable = methodAnnotations.contains("@Nullable") ? "@Nullable " : "";
      ImmutableSortedSet<String> allImports =
          ImmutableSortedSet.<String>naturalOrder()
              .add(GeneratedImport.importGeneratedAnnotationType())
              .addAll(imports)
              .build();
      ImmutableList<String> list =
          ImmutableList.<String>builder()
              .add("package foo.bar;", "")
              .addAll(allImports)
              .add(
                  "",
                  "@Generated(\"" + AutoValueProcessor.class.getName() + "\")",
                  "final class AutoValue_Baz extends Baz {")
              .addAll(fieldAnnotations)
              .add(
                  "  private final int buh;",
                  "  AutoValue_Baz(" + nullable + "int buh) {",
                  "    this.buh = buh;",
                  "  }",
                  "")
              .addAll(methodAnnotations)
              .add(
                  "  @Override public int buh() {",
                  "    return buh;",
                  "  }",
                  "",
                  "  @Override public String toString() {",
                  "    return \"Baz{\"",
                  "        + \"buh=\" + buh",
                  "        + \"}\";",
                  "  }",
                  "",
                  "  @Override public boolean equals(Object o) {",
                  "    if (o == this) {",
                  "      return true;",
                  "    }",
                  "    if (o instanceof Baz) {",
                  "      Baz that = (Baz) o;",
                  "      return this.buh == that.buh();",
                  "    }",
                  "    return false;",
                  "  }",
                  "",
                  "  @Override public int hashCode() {",
                  "    int h$ = 1;",
                  "    h$ *= 1000003;",
                  "    h$ ^= buh;",
                  "    return h$;",
                  "  }",
                  "}")
              .build();

      String[] lines = list.toArray(new String[list.size()]);
      return JavaFileObjects.forSourceLines("foo.bar.AutoValue_Baz", lines);
    }
Tests to ensure annotations are kept on AutoValue generated classes

@author jmcampanini
value/src/test/java/com/google/auto/value/processor/PropertyAnnotationsTest.java