def isInjectable()

in jackson/src/main/scala/com/twitter/finatra/jackson/caseclass/DefaultAnnotationIntrospector.scala [57:96]


  def isInjectable(
    name: String,
    annotations: Array[Annotation]
  ): Boolean = {
    // dependency injection annotations -- cannot be used in combination with any JacksonAnnotation
    val injectionAnnotations =
      ReflectAnnotations.filterAnnotations(GuiceInjectableValues.InjectionAnnotations, annotations)
    // annotations that are annotated with `@InjectableValue` -- OK in combo with JacksonAnnotations,
    // though support for a given JacksonAnnotation may vary or be non-existent
    // depending on what `InjectableValues` implementation is configured
    val injectableValuesAnnotations =
      injectionAnnotations ++
        ReflectAnnotations.filterIfAnnotationPresent[InjectableValue](annotations)

    assert(
      injectableValuesAnnotations.length <= 1,
      "Only 1 injectable annotation allowed per field. " +
        "We found [" + injectableValuesAnnotations
        .map(_.annotationType.getName).mkString(", ") + s"] on field $name."
    )

    if (injectionAnnotations.nonEmpty) {
      // has one of `javax.inject.Inject`, `com.google.inject.Inject` or `com.fasterxml.jackson.annotation.JacksonInject`
      // should not also have any JacksonAnnotation
      val jacksonAnnotations =
        annotations.filter(a =>
          ReflectAnnotations.isAnnotationPresent[JacksonAnnotation](a) &&
            !ReflectAnnotations.equals[JacksonInject](a))
      assert(
        jacksonAnnotations.isEmpty,
        "Using JacksonAnnotations in combination with an annotation to " +
          "inject a field via dependency injection is not supported. " +
          "We found [" + (jacksonAnnotations ++ injectionAnnotations)
          .map(_.annotationType.getName).mkString(", ") + s"] on field $name."
      )
    }

    // is injectable if annotated with a supported injectable values annotation
    injectableValuesAnnotations.nonEmpty
  }