code: public static boolean hasOuterContext(TypeElement type) {
      switch (type.getNestingKind()) {
        case ANONYMOUS:
        case LOCAL:
          return !isStatic(type.getEnclosingElement());
        case MEMBER:
          return !isStatic(type);
        case TOP_LEVEL:
          return false;
      }
      throw new AssertionError("Unknown NestingKind");
    }
docs: Determines if a type element can access fields and methods from an outer class.