Reads the {@link Annotation} attribute's value from the given {@link AnnotatedElement}.

@param annotatedElement must not be {@literal null}.
@return
772261
@Nullable
	public String getValueFrom(AnnotatedElement annotatedElement) {

		Assert.notNull(annotatedElement, "Annotated element must not be null!");
		Annotation annotation = annotatedElement.getAnnotation(annotationType);
		return annotation == null ? null : getValueFrom(annotation);
	}
1312721
protected Class<?> getValueType(AnnotatedElement element) {
        if (element instanceof Field) {
            return ((Field) element).getType();
        }
        if (element instanceof Method) {
            return ((Method) element).getReturnType();
        }
        throw new PropertyLoaderException("Could not get element type");
    }
1138945
public static <T extends Enum<T>> T getElementValueEnum(AnnotationMirror anno, CharSequence name, Class<T> t, boolean useDefaults) {
        Symbol.VarSymbol vs = getElementValue(anno, name, Symbol.VarSymbol.class, useDefaults);
        T value = Enum.valueOf(t, vs.getSimpleName().toString());
        return value;
    }
990151
static void extractString(Elements elementUtils, Element item, Class<? extends Annotation> annotationClass, AnnotationAttributeType attribute, OnAttributeFoundListener listener) {
		extractAttributeValue(elementUtils, item, annotationClass.getCanonicalName(), attribute, listener);
	}
755315
public Binding toBinding(BindingElement element) {
		final TypeReference typeReference = typeRef(element.getBind());
		final String annotatedWith = element.getAnnotatedWith();
		final String annotatedWithName = element.getAnnotatedWithName();
		if (!Strings.isEmpty(annotatedWith)) {
			final TypeReference annotationType = typeRef(annotatedWith);
			if (element.isInstance()) {
				return bindAnnotatedWithToInstance(typeReference, annotationType, element.getTo(),
						element.getFunctionName());
			}
			final TypeReference typeReference2 = typeRef(element.getTo());
			return bindAnnotatedWith(typeReference, annotationType, typeReference2,
						element.getFunctionName());
		}
		if (!Strings.isEmpty(annotatedWithName)) {
			if (element.isInstance()) {
				return bindAnnotatedWithNameToInstance(typeReference, annotatedWithName,
						element.getTo(),
						element.getFunctionName());
			}
			final TypeReference typeReference2 = typeRef(element.getTo());
			return bindAnnotatedWithName(typeReference, annotatedWithName, typeReference2,
						element.getFunctionName());
		}
		if (element.isInstance()) {
			return bindToInstance(typeReference,
					element.getFunctionName(),
					element.getTo(),
					element.isSingleton(),
					element.isEager());
		}
		final TypeReference typeReference2 = typeRef(element.getTo());
		return bindToType(
					typeReference,
					element.getFunctionName(),
					typeReference2,
					element.isSingleton(),
					element.isEager(),
					element.isProvider());
	}
1243582
private Attribute attributeAnnotationValue(Type expectedElementType, JCExpression tree,
            Env<AttrContext> env)
    {
        //first, try completing the symbol for the annotation value - if acompletion
        //error is thrown, we should recover gracefully, and display an
        //ordinary resolution diagnostic.
        try {
            expectedElementType.tsym.complete();
        } catch(CompletionFailure e) {
            log.error(tree.pos(), "cant.resolve", Kinds.kindName(e.sym), e.sym);
            expectedElementType = syms.errType;
        }

        if (expectedElementType.hasTag(ARRAY)) {
            return getAnnotationArrayValue(expectedElementType, tree, env);

        }

        //error recovery
        if (tree.hasTag(NEWARRAY)) {
            if (!expectedElementType.isErroneous())
                log.error(tree.pos(), "annotation.value.not.allowable.type");
            JCNewArray na = (JCNewArray)tree;
            if (na.elemtype != null) {
                log.error(na.elemtype.pos(), "new.not.allowed.in.annotation");
            }
            for (List<JCExpression> l = na.elems; l.nonEmpty(); l=l.tail) {
                attributeAnnotationValue(syms.errType,
                        l.head,
                        env);
            }
            return new Attribute.Error(syms.errType);
        }

        if (expectedElementType.tsym.isAnnotationType()) {
            if (tree.hasTag(ANNOTATION)) {
                return attributeAnnotation((JCAnnotation)tree, expectedElementType, env);
            } else {
                log.error(tree.pos(), "annotation.value.must.be.annotation");
                expectedElementType = syms.errType;
            }
        }

        //error recovery
        if (tree.hasTag(ANNOTATION)) {
            if (!expectedElementType.isErroneous())
                log.error(tree.pos(), "annotation.not.valid.for.type", expectedElementType);
            attributeAnnotation((JCAnnotation)tree, syms.errType, env);
            return new Attribute.Error(((JCAnnotation)tree).annotationType.type);
        }

        if (expectedElementType.isPrimitive() ||
                (types.isSameType(expectedElementType, syms.stringType) && !expectedElementType.hasTag(TypeTag.ERROR))) {
            return getAnnotationPrimitiveValue(expectedElementType, tree, env);
        }

        if (expectedElementType.tsym == syms.classType.tsym) {
            return getAnnotationClassValue(expectedElementType, tree, env);
        }

        if (expectedElementType.hasTag(CLASS) &&
                (expectedElementType.tsym.flags() & Flags.ENUM) != 0) {
            return getAnnotationEnumValue(expectedElementType, tree, env);
        }

        //error recovery:
        if (!expectedElementType.isErroneous())
            log.error(tree.pos(), "annotation.value.not.allowable.type");
        return new Attribute.Error(attr.attribExpr(tree, env, expectedElementType));
    }
70645
public static boolean isAnnotationPresent(final AnnotatedElement annotatedElement, final Class<?> annotationClass) {
        return Stream.of(annotatedElement.getAnnotations()).map(Annotation::annotationType).map(Class::getName).anyMatch(n -> n.equals(annotationClass.getName()));
    }
1078087
private void readObject(java.io.ObjectInputStream in) 
                 throws IOException, ClassNotFoundException
    {
        in.defaultReadObject();

        if (_elemDesc == null)  // element is a Class
            _annotElem = _elemClass;
        else
        {
            int argsIndex = _elemDesc.indexOf('(');
            if (argsIndex < 0)  // element is a Field
            {
                try
                {
                    _annotElem = _elemClass.getDeclaredField(_elemDesc);
                }
                catch (NoSuchFieldException nsfe)
                {
                    throw new IOException("Unable to locate field " + nsfe);
                }
            }
            else // element is a method
            {
                String methodName = _elemDesc.substring(0, argsIndex);
                if (_elemDesc.charAt(argsIndex+1) == ')')
                {
                    // At least handle the null args case quickly
                    try
                    {
                        _annotElem = _elemClass.getDeclaredMethod(methodName, new Class [] {});
                    }
                    catch (NoSuchMethodException nsme)
                    {
                        throw new IOException("Unable to locate method " +_elemDesc);
                    }
                }
                else
                {
                    // Linear search for the rest :(
                    String methodArgs = _elemDesc.substring(argsIndex+1, _elemDesc.length()-1);
                    Method [] methods = _elemClass.getDeclaredMethods();
                    for (int i = 0; i < methods.length; i++)
                    {
                        if (methods[i].getName().equals(methodName) &&
                            getMethodArgs(methods[i]).equals(methodArgs))
                        {
                            _annotElem = methods[i];
                            break;
                        }
                    }

                    if (_annotElem == null)
                    {
                        throw new IOException("Unable to locate method " +  _elemDesc);
                    }
                }
            }
        }
    }
392309
public static String[] getFeatureAttribute(Annotation annotation) {

        try {

            // only annotations which are annotated with @FeatureAttribute are interesting
            FeatureAttribute details = annotation.annotationType().getAnnotation(FeatureAttribute.class);
            if (details != null) {

                // this is the name of the feature attribute
                String attributeName = details.value();

                // find the method to invoke on the annotation to read the value of the feature attribute
                Method method = annotation.getClass().getMethod(details.annotationAttribute());
                if (method != null) {
                    String attributeValue = method.invoke(annotation).toString();
                    return new String[]{attributeName, attributeValue};
                }

            }

        } catch (NoSuchMethodException e) {
            throw new IllegalStateException(e);
        } catch (SecurityException e) {
            throw new IllegalStateException(e);
        } catch (IllegalAccessException e) {
            throw new IllegalStateException(e);
        } catch (IllegalArgumentException e) {
            throw new IllegalStateException(e);
        } catch (InvocationTargetException e) {
            throw new IllegalStateException(e);
        }

        return null;

    }
167553
public static <T extends AnnotationDescription> ElementMatcher.Junction<T> is(Annotation annotation) {
        return is(AnnotationDescription.ForLoadedAnnotation.of(annotation));
    }
983174
private static <T> T getAnnotationValue(Annotation annotation, String value, Class<T> expectedType) {
        Class<? extends Annotation> annotationType = annotation.annotationType();
        Method valueMethod;
        try {
            valueMethod = annotationType.getDeclaredMethod(value);
        } catch (NoSuchMethodException e) {
            throw new IllegalStateException("Cannot resolve required method '" + value + "()' for '" + annotationType + "'.");
        }
        Object elementValue;
        try {
            elementValue = valueMethod.invoke(annotation);
        } catch (ReflectiveOperationException e) {
            throw new IllegalStateException("Cannot invoke method value() for " + annotationType);
        }
        return elementValue != null ? expectedType.cast(elementValue) : null;
    }
168125
private static List<TypeMirror> getAnnotationClassValues(Element member, Annotation annotation, String annotationMemberName) {
        for (AnnotationMirror annotationMirror : member.getAnnotationMirrors()) {
            if (((TypeElement) annotationMirror.getAnnotationType().asElement()).getQualifiedName().contentEquals(annotation.annotationType().getName())) {
                for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : annotationMirror.getElementValues().entrySet()) {
                    if (entry.getKey().getSimpleName().contentEquals(annotationMemberName)) {
                        @SuppressWarnings({ "unchecked", "rawtypes" })
                        List<AnnotationValue> types = (List) entry.getValue().getValue();
                        TypeMirror[] result = new TypeMirror[types.size()];
                        for (int i = 0; i < types.size(); i++) {
                            result[i] = (TypeMirror) types.get(i).getValue();
                        }
                        return Arrays.asList(result);
                    }
                }
                return Collections.emptyList();
            }
        }

        throw new IllegalStateException(annotation.annotationType().getName() + " not found in " + member);
    }
832296
protected AnnotationInstance parseAnnotationDesc(AnnotationDesc annotationDesc, String programElement) {
		AnnotationInstance annotationInstanceNode = objectFactory.createAnnotationInstance();

		try {
			AnnotationTypeDoc annotTypeInfo = annotationDesc.annotationType();
			annotationInstanceNode.setName(annotTypeInfo.name());
			annotationInstanceNode.setQualified(annotTypeInfo.qualifiedTypeName());
		} catch (ClassCastException castException) {
			log.error("Unable to obtain type data about an annotation found on: " + programElement);
			log.error("Add to the classpath the class/jar that defines this annotation.");
		}

		for (AnnotationDesc.ElementValuePair elementValuesPair : annotationDesc.elementValues()) {
			AnnotationArgument annotationArgumentNode = objectFactory.createAnnotationArgument();
			annotationArgumentNode.setName(elementValuesPair.element().name());

			Type annotationArgumentType = elementValuesPair.element().returnType();
			annotationArgumentNode.setType(parseTypeInfo(annotationArgumentType));
			annotationArgumentNode.setPrimitive(annotationArgumentType.isPrimitive());
			annotationArgumentNode.setArray(annotationArgumentType.dimension().length() > 0);

			Object objValue = elementValuesPair.value().value();
			if (objValue instanceof AnnotationValue[]) {
				for (AnnotationValue annotationValue : (AnnotationValue[]) objValue) {
				    if (annotationValue.value() instanceof AnnotationDesc) {
                        AnnotationDesc annoDesc = (AnnotationDesc) annotationValue.value();
                        annotationArgumentNode.getAnnotation().add(parseAnnotationDesc(annoDesc, programElement));
                    } else {
                        annotationArgumentNode.getValue().add(annotationValue.value().toString());
                    }
				}
			} else if (objValue instanceof FieldDoc) {
				annotationArgumentNode.getValue().add(((FieldDoc) objValue).name());
			} else if (objValue instanceof ClassDoc) {
				annotationArgumentNode.getValue().add(((ClassDoc) objValue).qualifiedTypeName());
			} else {
				annotationArgumentNode.getValue().add(objValue.toString());
			}
			annotationInstanceNode.getArgument().add(annotationArgumentNode);
		}

		return annotationInstanceNode;
	}
509781
public static ImmutableSet<? extends AnnotationMirror> getAnnotatedAnnotations(Element element,
      final Class<? extends Annotation> annotationType) {
    List<? extends AnnotationMirror> annotations = element.getAnnotationMirrors();
    return FluentIterable.from(annotations)
        .filter(new Predicate<AnnotationMirror>() {
          @Override public boolean apply(AnnotationMirror input) {
            return isAnnotationPresent(input.getAnnotationType().asElement(), annotationType);
          }
        })
        .toSet();
  }
706201
protected AnnotationElement parseAnnotationTypeElementDoc(AnnotationTypeElementDoc annotationTypeElementDoc) {
		AnnotationElement annotationElementNode = objectFactory.createAnnotationElement();
		annotationElementNode.setName(annotationTypeElementDoc.name());
		annotationElementNode.setQualified(annotationTypeElementDoc.qualifiedName());
		annotationElementNode.setType(parseTypeInfo(annotationTypeElementDoc.returnType()));

		AnnotationValue value = annotationTypeElementDoc.defaultValue();
		if (value != null) {
			annotationElementNode.setDefault(value.toString());
		}

		return annotationElementNode;
	}
954751
private void init(AnnotatedElement element) {
		Annotation[] declaredAnnotations = element.getDeclaredAnnotations();
		this.declaredAnnotationMap = new HashMap<>();
		parseDeclared(declaredAnnotations);
		
		Annotation[] annotations = element.getAnnotations();
		if(declaredAnnotations == annotations) {
			this.annotationMap = this.declaredAnnotationMap;
		}else {
			this.annotationMap = new HashMap<>();
			parse(annotations);
		}
	}
1278544
public static ILocalizableString get(AnnotatedElement element, String name) {
		for (LocalizableProperty p : element.getAnnotationsByType(LocalizableProperty.class)) {
			if (!p.name().equals(name)) continue;
			String ns = p.namespace();
			if (ns.length() == 0) {
				LocalizableNamespace lns = element.getAnnotation(LocalizableNamespace.class);
				if (lns == null) {
					if (element instanceof Member)
						lns = ((Member)element).getDeclaringClass().getAnnotation(LocalizableNamespace.class);
				}
				if (lns != null)
					ns = lns.value();
			}
			String[] values = p.values();
			Object[] v = new Object[values.length];
			for (int i = 0; i < values.length; ++i) v[i] = values[i];
			return new LocalizableString(ns, p.key(), v);
		}
		for (Property p : element.getAnnotationsByType(Property.class)) {
			if (!p.name().equals(name)) continue;
			return new FixedLocalizedString(p.value());
		}
		return null;
	}