static ElementFactory forAnnotatedElement(Element element, Messager messager) {
      /* The name of the ElementKind constants is used instead to accommodate for RECORD
       * and RECORD_COMPONENT kinds, which are introduced in Java 16.
       */
      switch (element.getKind().name()) {
        case "PACKAGE":
          return new PackageElementFactory(element);
        case "CLASS":
        case "ENUM":
        case "INTERFACE":
        case "ANNOTATION_TYPE":
        case "RECORD":
          return new TypeElementFactory(element);
        case "TYPE_PARAMETER":
          return new TypeParameterElementFactory(element, messager);
        case "FIELD":
        case "ENUM_CONSTANT":
        case "RECORD_COMPONENT":
          return new FieldOrRecordComponentElementFactory(element);
        case "CONSTRUCTOR":
        case "METHOD":
          return new ExecutableElementFactory(element);
        case "PARAMETER":
          return new ParameterElementFactory(element);
        default:
          messager.printMessage(
              WARNING,
              String.format(
                  "%s does not support element type %s.",
                  ElementFactory.class.getCanonicalName(), element.getKind()));
          return new UnsupportedElementFactory(element);
      }
    }
An {@link ElementFactory} for an annotated element.
common/src/main/java/com/google/auto/common/BasicAnnotationProcessor.java