package com.fasterxml.jackson.databind.introspect;

import com.fasterxml.jackson.annotation.JacksonInject;
import com.google.inject.BindingAnnotation;
import com.google.inject.Key;

import java.lang.annotation.Annotation;

/**
 */
public class GuiceAnnotationIntrospector extends NopAnnotationIntrospector
{
  @Override
  public Object findInjectableValueId(AnnotatedMember m)
  {
    if (m.getAnnotation(JacksonInject.class) == null) {
      return null;
    }

    Annotation guiceAnnotation = null;
    for (Annotation annotation : m.getAllAnnotations()._annotations.values()) {
      if (annotation.annotationType().isAnnotationPresent(BindingAnnotation.class)) {
        guiceAnnotation = annotation;
        break;
      }
    }

    if (guiceAnnotation == null) {
      return Key.get(m.getGenericType());
    }
    return Key.get(m.getGenericType(), guiceAnnotation);
  }
}

@@ -173,16 +173,46 @@
 ect.Key;
+%0Aimport com.metamx.common.IAE;
 %0A%0Aimport
@@ -786,32 +786,154 @@
 tion == null) %7B%0A
+      if (m instanceof AnnotatedMethod) %7B%0A        throw new IAE(%22Annotated methods don't work very well yet...%22);%0A      %7D%0A
       return Key

throw exception for annotated members