final void checkModifiersIfNested(TypeElement type) {
    ElementKind enclosingKind = type.getEnclosingElement().getKind();
    if (enclosingKind.isClass() || enclosingKind.isInterface()) {
      if (type.getModifiers().contains(Modifier.PRIVATE)) {
        errorReporter.abortWithError(
            "@" + simpleAnnotationName + " class must not be private", type);
      } else if (Visibility.effectiveVisibilityOfElement(type).equals(Visibility.PRIVATE)) {
        // The previous case, where the class itself is private, is much commoner so it deserves
        // its own error message, even though it would be caught by the test here too.
        errorReporter.abortWithError(
            "@" + simpleAnnotationName + " class must not be nested in a private class", type);
      }
      if (!type.getModifiers().contains(Modifier.STATIC)) {
        errorReporter.abortWithError(
            "Nested @" + simpleAnnotationName + " class must be static", type);
      }
    }
    // In principle type.getEnclosingElement() could be an ExecutableElement (for a class
    // declared inside a method), but since RoundEnvironment.getElementsAnnotatedWith doesn't
    // return such classes we won't see them here.
  }
final void checkModifiersIfNested ( TypeElement type ) { ElementKind enclosingKind = type . getEnclosingElement ( ) . getKind ( ) ; if ( enclosingKind . isClass ( ) || enclosingKind . isInterface ( ) ) { if ( type . getModifiers ( ) . contains ( Modifier . PRIVATE ) ) { errorReporter . abortWithError ( "@" + simpleAnnotationName + " class must not be private" , type ) ; } else if ( Visibility . effectiveVisibilityOfElement ( type ) . equals ( Visibility . PRIVATE ) ) { errorReporter . abortWithError ( "@" + simpleAnnotationName + " class must not be nested in a private class" , type ) ; } if ( ! type . getModifiers ( ) . contains ( Modifier . STATIC ) ) { errorReporter . abortWithError ( "Nested @" + simpleAnnotationName + " class must be static" , type ) ; } } }
Checks that, if the given {@code @AutoValue} or {@code @AutoOneOf} class is nested, it is
static and not private. This check is not necessary for correctness, since the generated code
would not compile if the check fails, but it produces better error messages for the user.