Build a qualifier for the given annotation.

@param annotation The annotation
@param <T>        The component type
@return The qualifier
4791
public static <T> Qualifier<T> byAnnotation(Annotation annotation) {
        if (annotation.annotationType() == Type.class) {
            Type typeAnn = (Type) annotation;
            return byType(typeAnn.value());
        } else if (annotation.annotationType() == Named.class) {
            Named nameAnn = (Named) annotation;
            return byName(nameAnn.value());
        } else {
            return new AnnotationQualifier<>(annotation);
        }
    }
135623
public static <T extends Annotation> AnnotationValueBuilder<T> builder(Class<T> annotation) {
        return new AnnotationValueBuilder<>(annotation);
    }
1074888
public static Class<? extends Annotation> checkIsBindingAnnotation(
      Class<? extends Annotation> annotation) {
    if (!isBindingAnnotation(annotation)) {
      throw new IllegalArgumentException(
          "Must be a binding annotation (BindingAnnotation or Qualifier)");
    }
    return annotation;
  }
1331629
public AnnotatedTypeBuilder<X> addToMethod(AnnotatedMethod<? super X> method, Annotation annotation) {
       return addToMethod(method.getJavaMember(), annotation);
   }
102330
public static <T extends Annotation> T getAnnotation(Method method, Class<T> annotationClass) {
        T t = method.getAnnotation(annotationClass);
        if (t == null) {
            t = getAnnotation(method.getDeclaringClass(), annotationClass);
        }
        return t;
    }
1015613
@SuppressWarnings("unchecked")
	public <T extends Annotation> T getAnnotation(Class<T> annotationType) {
		for (Annotation annotation : this.annotations) {
			if (annotation.annotationType().equals(annotationType)) {
				return (T) annotation;
			}
		}
		for (Annotation metaAnn : this.annotations) {
			T ann = metaAnn.annotationType().getAnnotation(annotationType);
			if (ann != null) {
				return ann;
			}
		}
		return null;
	}
225520
public <T extends Annotation> T getAnnotation(Class<T> annotationType) {
        Annotation value = annotations.get(annotationType);
        return annotationType.cast(value);
    }
33016
public static IAnnotationBinding getAnnotationBinding(
            IAnnotationBinding[] annotations, String annotationClassName) {
        if (annotations == null) {
            return null;
        }
        if (annotationClassName == null) {
            throw new NullPointerException();
        }

        for (IAnnotationBinding annotation : annotations) {
            String qName = annotation.getAnnotationType().getBinaryName();
            assert qName != null;
            // TODO if multiple annotations for annotationClassName exists
            if (qName.equals(annotationClassName)) {
                return annotation;
            }
        }
        return null;
    }
592289
public List<A> findAllAttributesByQualifier(String qualifier) {
        return (List<A>)getModelStore().findAllAttributesByQualifier(qualifier);
    }
722572
private String getAnnotationValue(Annotation annotation) {
        Class<? extends Annotation> type = annotation.annotationType();
        try {
            Method method = type.getDeclaredMethod(VALUE);
            return String.valueOf(method.invoke(annotation, NO_ARGS));
        } catch (NoSuchMethodException e) {
            return null;
        } catch (InvocationTargetException e) {
            return null;
        } catch (IllegalAccessException e) {
            return null;
        }
    }
1205074
public static <T extends Annotation> Optional<T> getAnnotation( String annotation, List<? extends HasAnnotations>
            hasAnnotationsList ) {
        try {
            Class clazz = Class.forName( annotation );
            return getAnnotation( clazz, hasAnnotationsList );
        } catch ( ClassNotFoundException e ) {
            return Optional.absent();
        }
    }
866817
static String createAnnotationId(Annotation annotation) {
        Method[] methods = doPrivileged(
            (PrivilegedAction<Method[]>) () -> annotation.annotationType().getDeclaredMethods());

        return Stream.of(methods)
            .filter(method -> !method.isAnnotationPresent(Nonbinding.class))
            .sorted(comparing(Method::getName))
            .collect(() -> new StringJoiner(",", "@" + annotation.annotationType().getCanonicalName() + "(", ")"),
                (joiner, method) -> {
                    try {
                        joiner.add(method.getName() + "=" + method.invoke(annotation).toString());
                    } catch (NullPointerException | IllegalArgumentException | IllegalAccessException | InvocationTargetException cause) {
                        throw new RuntimeException(
                            "Error while accessing member [" + method.getName() + "]"
                            + " of annotation [" + annotation.annotationType().getName() + "]", cause);
                    }
                },
                StringJoiner::merge)
            .toString();
    }
937089
private void checkBindings(EnhancedAnnotation<T> annotatedAnnotation) {
        Set<Annotation> bindings = annotatedAnnotation.getMetaAnnotations(Qualifier.class);
        if (bindings.size() > 0) {
            for (Annotation annotation : bindings) {
                if (!annotation.annotationType().equals(Named.class)) {
                    throw MetadataLogger.LOG.qualifierOnStereotype(annotatedAnnotation);
                }
            }
        }
    }
591981
public static <A extends Annotation> A getAnnotation(final Class<A> annotation, final Method method) {
        try {
            return DaemonScanner.isAnnotationPresent(annotation, method.getDeclaringClass(), method.getName(), method.getParameterTypes());
        } catch(final NoSuchMethodException e) {
            return null;
        }
    }
770058
public void buildAnnotationTypeSignature(XMLNode node, Content annotationInfoTree) {
        StringBuilder modifiers = new StringBuilder(
                annotationTypeDoc.modifiers() + " ");
        writer.addAnnotationTypeSignature(Util.replaceText(
                modifiers.toString(), "interface", "@interface"), annotationInfoTree);
    }
203328
public static <T> T getAnnotation(final Class c, final Class<T> annotation) {
        final List<T> found = getAnnotations(c, annotation);
        if (found != null && !found.isEmpty()) {
            return found.get(0);
        } else {
            return null;
        }
    }
1037016
@DefinedBy(Api.LANGUAGE_MODEL)
    public <A extends Annotation> A getAnnotation(Class<A> annoType) {

        if (!annoType.isAnnotation())
            throw new IllegalArgumentException("Not an annotation type: " + annoType);

        Attribute.Compound c = getAttribute(annoType);
        return c == null ? null : AnnotationProxyMaker.generateAnnotation(c, annoType);
    }