Extract from an annotation of a method the attribute value specified.

@param item the item
@param annotationClass the annotation class
@param attributeName the attribute name
@return attribute value extracted as class typeName
17092
public static String extractAsClassName(Element item, Class<? extends Annotation> annotationClass, AnnotationAttributeType attributeName) {
		final Elements elementUtils=BindDataSourceSubProcessor.elementUtils;
		final One<String> result = new One<String>();

		extractString(elementUtils, item, annotationClass, attributeName, new OnAttributeFoundListener() {

			@Override
			public void onFound(String value) {
				result.value0 = AnnotationUtility.extractAsArrayOfClassName(value).get(0);
			}
		});

		return result.value0;
	}
1048929
public static <T extends Annotation> Optional<T> getAnnotation(Class<?> beanClass, Class<T> annotationClass) {
		Class<?> currentClass = beanClass;
		while (currentClass != null && currentClass != Object.class) {
			if (currentClass.isAnnotationPresent(annotationClass)) {
				return Optional.of(currentClass.getAnnotation(annotationClass));
			}
			currentClass = currentClass.getSuperclass();
		}

		return Optional.empty();
	}
1158868
protected Tag getModelTag(Class<?> modelClass) {
        if (modelClass.isAnnotationPresent(ApiModel.class)) {
            ApiModel annotation = modelClass.getAnnotation(ApiModel.class);
            Tag tag = new Tag();
            tag.setName(Optional.fromNullable(Strings.emptyToNull(annotation.name())).or(modelClass.getSimpleName()));
            tag.setDescription(translate(annotation.descriptionKey(), annotation.description()));
            return tag;
        }

        Tag tag = new Tag();
        tag.setName(modelClass.getName());
        return tag;
    }
390236
public static AnnotationNode getAnnotation(AnnotatedNode node, String name) {
        List<AnnotationNode> annotations = node.getAnnotations();
        for (AnnotationNode annot : annotations) {
            if (annot.getClassNode().getName().equals(name)) {
                return annot;
            }
        }
        return null;
    }
7335
private List<Pair<MethodSymbol, Attribute>> attributeAnnotationValues(JCAnnotation a,
            Type expected, Env<AttrContext> env)
    {
        // The annotation might have had its type attributed (but not
        // checked) by attr.attribAnnotationTypes during MemberEnter,
        // in which case we do not need to do it again.
        Type at = (a.annotationType.type != null ?
                a.annotationType.type : attr.attribType(a.annotationType, env));
        a.type = chk.checkType(a.annotationType.pos(), at, expected);

        boolean isError = a.type.isErroneous();
        if (!a.type.tsym.isAnnotationType() && !isError) {
            log.error(a.annotationType.pos(),
                    "not.annotation.type", a.type.toString());
            isError = true;
        }

        // List of name=value pairs (or implicit "value=" if size 1)
        List<JCExpression> args = a.args;

        boolean elidedValue = false;
        // special case: elided "value=" assumed
        if (args.length() == 1 && !args.head.hasTag(ASSIGN)) {
            args.head = make.at(args.head.pos).
                    Assign(make.Ident(names.value), args.head);
            elidedValue = true;
        }

        ListBuffer<Pair<MethodSymbol,Attribute>> buf = new ListBuffer<>();
        for (List<JCExpression> tl = args; tl.nonEmpty(); tl = tl.tail) {
            Pair<MethodSymbol, Attribute> p = attributeAnnotationNameValuePair(tl.head, a.type, isError, env, elidedValue);
            if (p != null && !p.fst.type.isErroneous())
                buf.append(p);
        }
        return buf.toList();
    }
870151
public static boolean extractAsBoolean(Element item, Class<? extends Annotation> annotationClass, AnnotationAttributeType attribute) {
		final Elements elementUtils=BaseProcessor.elementUtils;
		final One<Boolean> result = new One<Boolean>(false);

		extractString(elementUtils, item, annotationClass, attribute, new OnAttributeFoundListener() {

			@Override
			public void onFound(String value) {
				result.value0 = Boolean.parseBoolean(value);
			}
		});

		return result.value0;
	}
1059967
public static <T> List<Field> getAnnotatedFields(Object object, Class<? extends Annotation> annotationClass) {
		return getAnnotatedFields(object.getClass(), annotationClass);
	}
822572
public <T> T getAnnotation(Class<T> annotationClass) {
        for (Annotation annotation : m_annotations) {
            if (annotation.annotationType().equals(annotationClass)){
                return (T) annotation;
            }
        }
        return null;
    }
577635
private <T extends Annotation> T findAnnotation(Class<?> cls, Class<T> annotationClass, String name) {
    Class<?> curr = cls;
    T ann = null;
    while (ann == null && curr != null && !curr.equals(Object.class)) {
      ann = findAnnotationLocal(curr, annotationClass, name);
      curr = curr.getSuperclass();
    }
    return ann;
  }
37164
public JAnnotation getAnnotation(String className)
  {
    for (JAnnotation ann : getDeclaredAnnotations()) {
      if (ann.getType().equals(className))
        return ann;
    }
    
    return null;
  }
725256
public static Object getAnnotationAttribute(final Annotation annotation, final String attributeName) {
        Object object = null;
        try {
            // Get the annotation method for the given name
            final Method attributeMethod = annotation.annotationType().getDeclaredMethod(attributeName);

            // Call the method to gets the value
            object = attributeMethod.invoke(annotation);

        } catch (NoSuchMethodException | SecurityException e) {
            LOGGER.log(NO_ANNOTATION_PROPERTY, e, attributeName);
        } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
            LOGGER.log(NO_ANNOTATION_PROPERTY_VALUE, e, attributeName);
        }
        return object;
    }
487900
public static <A extends Annotation> A findAnnotation(Class<?> clazz, Class<A> annotationType) {
		if (clazz == null) throw new IllegalArgumentException("Clazz parameter can't be null");
		
		A annotation = clazz.getAnnotation(annotationType);
		if (annotation != null) return annotation;
		
		for (Class<?> ifc : clazz.getInterfaces()) {
			annotation = findAnnotation(ifc, annotationType);
			if (annotation != null) return annotation;
		}
		
		if (!Annotation.class.isAssignableFrom(clazz))
			for (Annotation ann : clazz.getAnnotations()) {
				annotation = findAnnotation(ann.annotationType(), annotationType);
				if (annotation != null) return annotation;
			}
		
		Class<?> superClass = clazz.getSuperclass();
		if (superClass == null || superClass == Object.class) return null;
		return findAnnotation(superClass, annotationType);
	}
767046
private <T> T getAnnotationValue(String attribute, Class<T> type) {

		Query annotation = method.getAnnotation(Query.class);
		Object value = annotation == null ? AnnotationUtils.getDefaultValue(Query.class, attribute) : AnnotationUtils
				.getValue(annotation, attribute);

		return type.cast(value);
	}
1082813
@Nullable
  private static <A extends Annotation> A getAnnotation(PropertyDescriptor descriptor,
      Class<A> type) {
    A a = null;
    if (descriptor.getWriteMethod() != null) {
      a = descriptor.getWriteMethod().getAnnotation(type);
    }
    if (a == null && descriptor.getReadMethod() != null) {
      a = descriptor.getReadMethod().getAnnotation(type);
    }
    return a;
  }
451398
public static Predicate<Annotation> annotationIsOfClass(final Class<? extends Annotation> annotationClass) {
        return candidate -> candidate != null && candidate.annotationType().equals(annotationClass);
    }
561956
public AnnotationNode annotation(String annotation) {
        this.attr(ANNOTATION, annotation);
        String[] kc = AnnotationParser.extractKeyAndContent(annotation);
        this.attr(ANNOTATION_KEY, kc[0]);
        this.attr(ANNOTATION_CONTENT, kc[1]);
        return this;
    }
74824
@SuppressWarnings("unchecked")
    public static <T> Optional<T> getAnnotationAttribute(final Annotation anno, final String attrName, final Class<T> attrType) {
        
        try {
            final Method method = anno.annotationType().getMethod(attrName);
            method.setAccessible(true);
            if(!attrType.equals(method.getReturnType())) {
                return Optional.empty();
            }
            
            final Object value = method.invoke(anno);
            return Optional.of((T)value);
            
        } catch (Exception e) {
            return Optional.empty();
        }
        
    }