Checks that no given annotations are present on given method
765988
@SafeVarargs
    private static void checkNoAnnotations(Method method, Class<? extends Annotation> foundAn,
            Class<? extends Annotation>... disallowedAn) {

        for (Class<? extends Annotation> an : disallowedAn) {
            if (method.isAnnotationPresent(an)) {
                throw new EventsException("Method " + Utils.methodToString(method)
                        + " marked with @" + foundAn.getSimpleName()
                        + " cannot be marked with @" + an.getSimpleName());
            }
        }
    }
282926
private void checkMethod(String methodName, String signature) {
    JavaClass javaClass = checkClass();
    if (javaClass == null) {
      return;
    }

    for (JavaClass current = javaClass; current != null; current = getSuperclass(current)) {
      for (Method method : current.getMethods()) {
        if (methodName.equals(method.getName()) && signature.equals(method.getSignature())) {
          // method has been found - check if it's beta
          if (isBeta(method.getAnnotationEntries())) {
            bugReporter.reportBug(createBugInstance(BETA_METHOD_USAGE).addCalledMethod(this));
          }
          return;
        }
      }
    }
    if (!javaClass.isAbstract()) {
      bugReporter.logError(
          "Can't locate method " + javaClass.getClassName() + "." + methodName + signature);
    }
  }
755124
def check_is_not_created(method):
    
    def check(self, *args, **kwargs):
        if self.id is not None:
            raise AlreadyCreatedError('%s.id %s already exists.' %
                                     (self.__class__.__name__, self.id))
        return method(self, *args, **kwargs)
    return check
530666
public static <A extends Annotation> List<A> getRepeatableAnnotations(Method method, Class<A> annotationClass) {
        A[] annotations = method.getAnnotationsByType(annotationClass);
        if (annotations == null || annotations.length == 0) {
            for (Annotation metaAnnotation : method.getAnnotations()) {
                annotations = metaAnnotation.annotationType().getAnnotationsByType(annotationClass);
                if (annotations != null && annotations.length > 0) {
                    return Arrays.asList(annotations);
                }
            }
            Method superclassMethod = getOverriddenMethod(method);
            if (superclassMethod != null) {
                return getRepeatableAnnotations(superclassMethod, annotationClass);
            }
        }
        if (annotations == null) {
            return null;
        }
        return Arrays.asList(annotations);
    }
515267
private void checkInnerClass(ClassDeclaration jclass)
            throws FatalCompileTimeException
    {
        boolean noFormBeanAnnotation = true;
        if (CompilerUtils.getAnnotation(jclass, FORM_BEAN_TAG_NAME, true) != null) {
            noFormBeanAnnotation = false;
        }
        else {
            //
            // check the methods for validatable property annotations that
            // would be processed elsewhere.
            //
            MethodDeclaration[] methods = CompilerUtils.getClassMethods(jclass, null);
            for (int i = 0; i < methods.length && noFormBeanAnnotation; i++) {
                MethodDeclaration method = methods[i];
                if (CompilerUtils.getAnnotation(method, VALIDATABLE_PROPERTY_TAG_NAME) != null) {
                    noFormBeanAnnotation = false;
                }
            }
        }

        if (noFormBeanAnnotation) {
            _formBeanChecker.check(jclass);
        }
    }
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;
        }
    }
1105250
@SuppressWarnings("unchecked")
    @SafeVarargs
    public final boolean containsAnnotations(Class<? extends Annotation>... annotationClass) {
        if (ArrayUtils.isEmpty(annotationClass)) {
            return false;
        }

        for (Object anno : getAnnotations()) {
            for (Class cls : annotationClass) {
                if (((Annotation) anno).annotationType().equals(cls)) {
                    return true;
                }
            }
        }
        return false;
    }
919348
def check_params_types(self, method):
        ''''''
        mn = method.__name__
        annos = dict(method.__annotations__)
        errors = []
        # Take a look at the syntax
        msg_tuple = 'Parameter {} in method {} is not annotated with a tuple.'
        msg_ptype = 'Parameter {} in method {} is not a valid Ptype.'
        msg_mod = 'Type for param {} in method {} must descend from Model.'
        msg_cls = 'Type for param {} in method {} must be instance (not class)'
        bodies = []
        for pname, anno in annos.items():
            if pname == 'return':
                continue
            elif len(anno) != 2:
                errors.append(msg_tuple.format(pname, mn))
            else:
                param_type, value_type = anno
                if param_type not in Ptypes:
                    errors.append(msg_ptype.format(pname, mn))
                elif param_type == 'body':
                    bodies.append(pname)
                elif param_type == 'path':
                    default = method.signature.parameters[pname].default
                    if default is not inspect._empty:
                        msg = ('Path prameter {} in method {} has a default '
                               'value ({}) that would make it optional (which '
                               'is wrong!)')
                        errors.append(msg.format(pname, mn, default))
                if hasattr(value_type, '__bases__'):
                    errors.append(msg_cls.format(pname, mn))
                elif Model not in value_type.__class__.__bases__:
                    errors.append(msg_mod.format(pname, mn))
        # Only one body parameter!
        if len(bodies) > 1:
            msg = 'Too many "Ptypes.body" params {} for method {} (max=1).'
            errors.append(msg.format(bodies, mn))
        return errors
571720
public boolean containsRequiredAnnotations(Collection<Class<? extends Annotation>> requiredAnnotations) {
        if (annotatedType instanceof BackedAnnotatedType<?>) {
            return containsAnnotation((BackedAnnotatedType<?>) annotatedType, requiredAnnotations);
        } else if (annotatedType instanceof UnbackedAnnotatedType<?>) {
            return containsAnnotation((UnbackedAnnotatedType<?>) annotatedType, requiredAnnotations);
        } else {
            throw new IllegalArgumentException("Unknown SlimAnnotatedType implementation: " + annotatedType.getClass().toString());
        }
    }
457322
private <Y> void checkObserverMethod(EnhancedAnnotatedMethod<T, Y> annotated) {
        // Make sure exactly one and only one parameter is annotated with Observes or ObservesAsync
        List<EnhancedAnnotatedParameter<?, Y>> eventObjects = annotated.getEnhancedParameters(Observes.class);
        eventObjects.addAll(annotated.getEnhancedParameters(ObservesAsync.class));
        if (this.reception.equals(Reception.IF_EXISTS) && declaringBean.getScope().equals(Dependent.class)) {
            throw EventLogger.LOG.invalidScopedConditionalObserver(this, Formats.formatAsStackTraceElement(annotated.getJavaMember()));
        }
        if (eventObjects.size() > 1) {
            throw EventLogger.LOG.multipleEventParameters(this, Formats.formatAsStackTraceElement(annotated.getJavaMember()));
        }
        EnhancedAnnotatedParameter<?, Y> eventParameter = eventObjects.iterator().next();
        checkRequiredTypeAnnotations(eventParameter);
        // Check for parameters annotated with @Disposes
        List<?> disposeParams = annotated.getEnhancedParameters(Disposes.class);
        if (disposeParams.size() > 0) {
            throw EventLogger.LOG.invalidDisposesParameter(this, Formats.formatAsStackTraceElement(annotated.getJavaMember()));
        }
        // Check annotations on the method to make sure this is not a producer
        // method, initializer method, or destructor method.
        if (this.observerMethod.getAnnotated().isAnnotationPresent(Produces.class)) {
            throw EventLogger.LOG.invalidProducer(this, Formats.formatAsStackTraceElement(annotated.getJavaMember()));
        }
        if (this.observerMethod.getAnnotated().isAnnotationPresent(Inject.class)) {
            throw EventLogger.LOG.invalidInitializer(this, Formats.formatAsStackTraceElement(annotated.getJavaMember()));
        }
        boolean containerLifecycleObserverMethod = Observers.isContainerLifecycleObserverMethod(this);
        for (EnhancedAnnotatedParameter<?, ?> parameter : annotated.getEnhancedParameters()) {
            // if this is an observer method for container lifecycle event, it must not inject anything besides BeanManager
            if (containerLifecycleObserverMethod && !parameter.isAnnotationPresent(Observes.class) && !parameter.isAnnotationPresent(ObservesAsync.class) && !BeanManager.class.equals(parameter.getBaseType())) {
                throw EventLogger.LOG.invalidInjectionPoint(this, Formats.formatAsStackTraceElement(annotated.getJavaMember()));
            }
        }

    }
663427
protected final boolean checkRequiredAnnotations(Class<?> controllerClazz, Method actionMethod) {
        List<Class<? extends Annotation>> requiredAnnotations = getRequiredAnnotationClasses();
        if (requiredAnnotations == null || requiredAnnotations.size() == 0) {
            return true;
        }
        for (Class<? extends Annotation> requiredAnnotation : requiredAnnotations) {
            if (requiredAnnotation == null) {
                continue;
            }
            BitSet scopeSet = getAnnotationScope(requiredAnnotation);
            if (scopeSet.get(AnnotationScope.METHOD.ordinal())) {
                if (actionMethod.isAnnotationPresent(requiredAnnotation)) {
                    return checkAnnotation(actionMethod.getAnnotation(requiredAnnotation));
                }
            }
            if (scopeSet.get(AnnotationScope.CLASS.ordinal())) {
                if (controllerClazz.isAnnotationPresent(requiredAnnotation)) {
                    return checkAnnotation(actionMethod.getAnnotation(requiredAnnotation));
                }
            }
            if (scopeSet.get(AnnotationScope.ANNOTATION.ordinal())) {
                for (Annotation annotation : actionMethod.getAnnotations()) {
                    if (annotation.annotationType().isAnnotationPresent(requiredAnnotation)) {
                        return checkAnnotation(actionMethod.getAnnotation(requiredAnnotation));
                    }
                }
                for (Annotation annotation : controllerClazz.getAnnotations()) {
                    if (annotation.annotationType().isAnnotationPresent(requiredAnnotation)) {
                        return checkAnnotation(actionMethod.getAnnotation(requiredAnnotation));
                    }
                }
            }
        }
        return false;
    }
1277214
private void checkCallbackMethods() throws CoreException {

        for (final EnumEventType eet : getAnnotationValue()) {

            final String methodName = buildHandlingMethodName(eet);

            final Class<?> eventClass = getAnnotationApiEventClass();

            try {
                this.callbackObject.getClass().getDeclaredMethod(methodName, eventClass);
            } catch (NoSuchMethodException | SecurityException e) {
                throw new CoreException(NO_EVENT_CALLBACK.getText(this.callbackObject.getClass().getName(), methodName, eventClass.getName()), e);
            }
        }

    }
947872
private static String findPattern(Method method, Set<Annotation> methodAnnotations) {
        String pattern = findFirst(method, Path.class).map(Path::value)
                                                      .orElse(null);
        for (Annotation a : methodAnnotations) {
            final String p = (String) invokeValueMethod(a);
            if (DefaultValues.isUnspecified(p)) {
                continue;
            }
            checkArgument(pattern == null,
                          "Only one path can be specified. (" + pattern + ", " + p + ')');
            pattern = p;
        }
        if (pattern == null || pattern.isEmpty()) {
            throw new IllegalArgumentException(
                    "A path pattern should be specified by @Path or HTTP method annotations.");
        }
        return pattern;
    }
853836
static <T extends Annotation> T findAnnotation(Method method, Class<T> clazz) {
		T annotation = AnnotationUtils.findAnnotation(method, clazz);
		if (annotation == null) {
			try {
				annotation = AnnotationUtils.findAnnotation(method.getDeclaringClass()
						.getMethod(method.getName(), method.getParameterTypes()), clazz);
			}
			catch (NoSuchMethodException | SecurityException ex) {
				if (log.isDebugEnabled()) {
					log.debug("Exception occurred while tyring to find the annotation",
							ex);
				}
			}
		}
		return annotation;
	}
247799
public static boolean hasAnnotation(ExecutableElement method, Class<? extends Annotation> ann) {
        List<? extends AnnotationMirror> annotationMirrors = method.getAnnotationMirrors();
        for (AnnotationMirror annotationMirror : annotationMirrors) {
            if (annotationMirror.getAnnotationType().toString().equals(ann.getName())) {
                return true;
            }
        }
        return false;
    }
1373676
private List<Class<?>> getValidJPAAnnotationsFromMethod(Class<?> clazz, Method method, int numberOfParams,
            Class<?> entityClazz)
    {
        List<Class<?>> annotations = new ArrayList<Class<?>>();

        for (Annotation methodAnnotation : method.getAnnotations())
        {
            Class<?> methodAnnotationType = methodAnnotation.annotationType();

            if (isValidJPAEntityListenerAnnotation(methodAnnotationType))
            {

                // verify method signature

                // verify exceptions
                boolean hasUncheckedExceptions = false;
                for (Class<?> exception : method.getExceptionTypes())
                {
                    if (!ReflectUtils.hasSuperClass(RuntimeException.class, exception))
                    {
                        hasUncheckedExceptions = true;
                        break;
                    }
                }

                if (hasUncheckedExceptions)
                {
                    log.info("Skipped method(" + clazz.getName() + "." + method.getName()
                            + ") Must not throw unchecked exceptions.");
                    continue;
                }

                // return type must be "void"
                if (!method.getReturnType().getSimpleName().equals("void"))
                {
                    log.info("Skipped method(" + clazz.getName() + "." + method.getName()
                            + ") Must have \"void\" return type.");
                    continue;
                }
                // argument must be an Entity or Object
                Class<?>[] paramTypes = method.getParameterTypes();
                if (paramTypes.length != numberOfParams)
                {
                    log.info("Skipped method(" + clazz.getName() + "." + method.getName() + ") Must have "
                            + numberOfParams + " parameter.");
                    continue;
                }

                if (numberOfParams == 1)
                {
                    Class<?> parameter = paramTypes[0];
                    if (!(parameter != null && parameter.isAssignableFrom(entityClazz)))
                    {
                        log.info("Skipped method(" + clazz.getName() + "." + method.getName()
                                + ") Must have only 1 \"Object\" type parameter.");
                        continue;
                    }
                }

                annotations.add(methodAnnotationType);
            }
        }
        return annotations;
    }
204028
private static boolean absentAnySetter(Method jsonAnyGetter, Method jsonAnySetter) {
        return (jsonAnySetter == null && jsonAnyGetter != null) ||
                (jsonAnySetter != null && jsonAnyGetter == null);
    }