14

When trying to use @AutoValue with nested classes:

public class Nested {
  @AutoValue
  public static abstract class Example {
    public static Example create(String name, int integer) {
      return new AutoValue_Example(name, integer);
    }
    public abstract String name();
    public abstract int integer();
  }
}

I get a compiler error cannot find symbol for AutoValue_Example. Any ideas on what I'm doing wrong?

Thomas Broyer
  • 64,353
  • 7
  • 91
  • 164
Amitha Perera
  • 143
  • 1
  • 4

2 Answers2

23

When your class is nested like this, the generated AutoValue class would be named AutoValue_Nested_Example. As stated in the docs:

Nesting

For a nested abstract value type called Foo.Bar.Qux, the generated implementation class is named AutoValue_Foo_Bar_Qux.

Community
  • 1
  • 1
Louis Wasserman
  • 191,574
  • 25
  • 345
  • 413
0

The inner class (in case it is static) is generated in a separated source file named 'AutoValue_outerClass_innerClass'

Efi G
  • 937
  • 8
  • 15