Do not refer to the autogenerated AutoValue_ class outside the file containing the corresponding @AutoValue base class.


The problem

@AutoValue-annotated classes may form part of your API, but the AutoValue_ generated classes should not. The fact that the generated classes are visible to other classes within the same package is an implementation detail, and is best avoided. Ideally, any reference to the AutoValue_-prefixed class should be confined to a single factory method, with other factories delegating to it if necessary.


Suppress false positives by adding the suppression annotation @SuppressWarnings("AutoValueSubclassLeaked") to the enclosing element.