Verifies if the given $caster supports casting with $method.
If not, an exception is raised.

@param  Caster $caster
@param  string $method
@param  string $annotationType
@throws Exception
518664
protected function verifyCastingSupport(Caster $caster, $method, $annotationType)
    {
        if (!method_exists($caster, $method)) {
            $message  = sprintf(
                'You are trying to map a property wich seems not to have a standard type (%s). Do you have a typo in your annotation?'.
                'If you think everything\'s ok, go check on %s class which property types are supported.',
                $annotationType,
                get_class($caster)
            );

            throw new Exception($message);
        }
    }
257521
protected void initType() {
        try {
            this.type = getEnhancedAnnotated().getJavaClass();
        } catch (ClassCastException e) {
            Type type = Beans.getDeclaredBeanType(getClass());
            throw BeanLogger.LOG.producerCastError(getEnhancedAnnotated().getJavaClass(), (type == null ? " unknown " : type), e);
        }
    }
124327
public static void assertNotVoidType(final Field field, Class<? extends Annotation> annotation)
   {
      if ((field.getClass().equals(Void.class)) && (field.getClass().equals(Void.TYPE)))
      {
         throw annotation == null ? MESSAGES.fieldCannotBeOfPrimitiveOrVoidType(field) : MESSAGES.fieldCannotBeOfPrimitiveOrVoidType2(field, annotation);
      }
   }
1258956
public <T extends Annotation> T getAnnotation(Class<T> annotationType) {
        return method.getAnnotation(annotationType);
    }
924264
protected function validateMethodAttribute(AttributeAnnotation $annotation, \ReflectionMethod $method)
    {
        if (! $method->isPublic()) {
            throw new \LogicException(sprintf(
                'Attribute annotation can be applied only to non public method "%s".',
                $method->getName()
            ));
        }

        if ($annotation->getter !== null) {
            throw new \LogicException(sprintf(
                'The "getter" property of Attribute annotation applied to method "%s" is useless.',
                $method->getName()
            ));
        }
    }
252054
private void validateMethod(Method method, CallbackType callbackType) {
    int modifiers = method.getModifiers();
    if (!Modifier.isPublic(modifiers)) {
      String message = String.format("Method %s in class %s must be public", method.getName(),
          method.getDeclaringClass().getName());
      throw new EntityManagerException(message);
    }
    if (Modifier.isStatic(modifiers)) {
      String message = String.format("Method %s in class %s must not be static", method.getName(),
          method.getDeclaringClass().getName());
      throw new EntityManagerException(message);
    }
    if (Modifier.isAbstract(modifiers)) {
      String message = String.format("Method %s in class %s must not be abstract", method.getName(),
          method.getDeclaringClass().getName());
      throw new EntityManagerException(message);
    }
    Class<?>[] parameters = method.getParameterTypes();
    if (parameters.length != 0) {
      String pattern = "Method %s in class %s is not a valid %s callback method. Method must not "
          + "have any parameters. ";
      String message = String.format(pattern, method.getName(),
          method.getDeclaringClass().getName(), callbackType);
      throw new EntityManagerException(message);
    }
    if (method.getReturnType() != void.class) {
      String message = String.format("Method %s in class %s must have a return type of %s",
          method.getName(), method.getDeclaringClass().getName(), void.class.getName());
      throw new EntityManagerException(message);
    }
  }
1360591
public static function readMethod( $method , $annotation = null ) {

		$ref = $method instanceof ReflectionMethod ? $method : new ReflectionMethod( $method[0] , $method[1] );

		return $annotation ? static::reader()->getMethodAnnotation( $ref , $annotation ) : static::reader()->getMethodAnnotations( $ref );

	}
632957
private static <T extends Annotation, R> Builder<R> getAnnotatedInstances(
            AnnotatedElement method, AnnotatedElement clazz, Class<T> annotationType, Class<R> resultType) {
        final Builder<R> builder = new Builder<>();
        Stream.concat(findAll(method, annotationType).stream(),
                      findAll(clazz, annotationType).stream())
              .forEach(annotation -> builder.add(getInstance(annotation, resultType)));
        return builder;
    }
1224433
public function scopeCast($query, Caster $caster = null)
    {
        $caster = $caster ?: $this->findCaster();

        if ($this->exists) {
            return $caster->cast($this);
        }

        return $caster->cast($query->get());
    }
620394
@FFDCIgnore(IOException.class)
    public static Parameter applyAnnotations(Parameter parameter, Type type, List<Annotation> annotations, Components components, String[] classTypes, String[] methodTypes) {

        final AnnotationsHelper helper = new AnnotationsHelper(annotations, type);
        if (helper.isContext()) {
            return null;
        }
        if (parameter == null) {
            // consider it to be body param
            parameter = new ParameterImpl();
        }

        // first handle schema
        List<Annotation> reworkedAnnotations = new ArrayList<>(annotations);
        Annotation paramSchemaOrArrayAnnotation = getParamSchemaAnnotation(annotations);
        Schema schemaFromAnn = null;
        if (paramSchemaOrArrayAnnotation != null) {
            reworkedAnnotations.add(paramSchemaOrArrayAnnotation);
            if (paramSchemaOrArrayAnnotation instanceof org.eclipse.microprofile.openapi.annotations.media.Schema) {
                org.eclipse.microprofile.openapi.annotations.media.Schema schemaAnn = (org.eclipse.microprofile.openapi.annotations.media.Schema) paramSchemaOrArrayAnnotation;
                schemaFromAnn = AnnotationsUtils.getSchema(schemaAnn, components).orElse(null);
            }
        }

        ResolvedSchema resolvedSchema = ModelConverters.getInstance().resolveAnnotatedType(type, reworkedAnnotations, "");

        if (resolvedSchema.schema != null) {
            if (schemaFromAnn != null) {
                if (schemaFromAnn.getAllOf() != null) {
                    resolvedSchema.schema.setAllOf(schemaFromAnn.getAllOf());
                    resolvedSchema.schema.setType(null);
                }
                if (schemaFromAnn.getAnyOf() != null) {
                    resolvedSchema.schema.setAnyOf(schemaFromAnn.getAnyOf());
                    resolvedSchema.schema.setType(null);
                }
                if (schemaFromAnn.getOneOf() != null) {
                    resolvedSchema.schema.setOneOf(schemaFromAnn.getOneOf());
                    resolvedSchema.schema.setType(null);
                }
                if (schemaFromAnn.getNot() != null) {
                    resolvedSchema.schema.setNot(schemaFromAnn.getNot());
                    resolvedSchema.schema.setType(null);
                }
            }
            parameter.setSchema(resolvedSchema.schema);
        }
        resolvedSchema.referencedSchemas.forEach((key, schema) -> components.addSchema(key, schema));

        for (Annotation annotation : annotations) {
            if (annotation instanceof org.eclipse.microprofile.openapi.annotations.parameters.Parameter) {
                org.eclipse.microprofile.openapi.annotations.parameters.Parameter p = (org.eclipse.microprofile.openapi.annotations.parameters.Parameter) annotation;
                if (p.hidden()) {
                    return null;
                }
                if (StringUtils.isNotBlank(p.ref())) {
                    parameter.setRef(p.ref());
                }
                if (StringUtils.isNotBlank(p.description())) {
                    parameter.setDescription(p.description());
                }
                if (StringUtils.isNotBlank(p.name())) {
                    parameter.setName(p.name());
                }
                if (StringUtils.isNotBlank(p.in().toString())) {
                    ((ParameterImpl) parameter).setIn(Parameter.In.valueOf(p.in().toString().toUpperCase()));
                }
                if (StringUtils.isNotBlank(p.example())) {
                    try {
                        parameter.setExample(Json.mapper().readTree(p.example()));
                    } catch (IOException e) {
                        parameter.setExample(p.example());
                    }
                }
                if (p.deprecated()) {
                    parameter.setDeprecated(p.deprecated());
                }
                if (p.required()) {
                    parameter.setRequired(p.required());
                }
                if (p.allowEmptyValue()) {
                    parameter.setAllowEmptyValue(p.allowEmptyValue());
                }
                if (p.allowReserved()) {
                    parameter.setAllowReserved(p.allowReserved());
                }

                Map<String, Example> exampleMap = new HashMap<>();
                for (ExampleObject exampleObject : p.examples()) {
                    AnnotationsUtils.getExample(exampleObject).ifPresent(example -> exampleMap.put(AnnotationsUtils.getNameOfReferenceableItem(exampleObject), example));
                }
                if (exampleMap.size() > 0) {
                    parameter.setExamples(exampleMap);
                }

                Optional<Content> content = AnnotationsUtils.getContent(p.content(), classTypes, methodTypes, parameter.getSchema());
                if (content.isPresent()) {
                    parameter.setContent(content.get());
                    parameter.setSchema(null);
                }
                setParameterStyle(parameter, p);
                setParameterExplode(parameter, p);

            } else if (annotation.annotationType().getName().equals("javax.ws.rs.PathParam")) {
                try {
                    String name = (String) annotation.annotationType().getMethod("value").invoke(annotation);
                    if (StringUtils.isNotBlank(name)) {
                        parameter.setName(name);
                    }
                } catch (Exception e) {
                }
            } else if (annotation.annotationType().getName().equals("javax.validation.constraints.Size")) {
                try {
                    if (parameter.getSchema() == null) {
                        parameter.setSchema(new SchemaImpl().type(SchemaType.ARRAY));
                    }
                    if (parameter.getSchema().getType() == SchemaType.ARRAY) {
                        Integer min = (Integer) annotation.annotationType().getMethod("min").invoke(annotation);
                        if (min != null) {
                            parameter.getSchema().setMinItems(min);
                        }
                        Integer max = (Integer) annotation.annotationType().getMethod("max").invoke(annotation);
                        if (max != null) {
                            parameter.getSchema().setMaxItems(max);
                        }
                    }

                } catch (Exception e) {
                    //LOGGER.error("failed on " + annotation.annotationType().getName(), e);
                }
            }
        }
        final String defaultValue = helper.getDefaultValue();

        Schema paramSchema = parameter.getSchema();
        if (paramSchema == null) {
            if (parameter.getContent() != null && parameter.getContent().values().size() > 0) {
                paramSchema = parameter.getContent().values().iterator().next().getSchema();
            }
        }
        if (paramSchema != null) {
            if (paramSchema.getType() == SchemaType.ARRAY) {
                if (defaultValue != null) {
                    paramSchema.getItems().setDefaultValue(defaultValue);
                }
            } else {
                if (defaultValue != null) {
                    paramSchema.setDefaultValue(defaultValue);
                }
            }
        }
        return parameter;
    }
464348
public static <T extends Annotation> T getClosestAnnotation(Method method, Class<T> typeOfT) {
    T annotation = method.getAnnotation(typeOfT);
    if (annotation == null) {

      Class<?> clazzToIntrospect = method.getDeclaringClass();
      while (annotation == null && clazzToIntrospect != null) {
        annotation = clazzToIntrospect.getAnnotation(typeOfT);
        clazzToIntrospect = clazzToIntrospect.getSuperclass();
      }
    }

    return annotation;
  }
517134
public void addAnnotation(String type) {
		if (!Strings.isEmpty(type)) {
			XAnnotation annotation = XAnnotationsFactory.eINSTANCE.createXAnnotation();
			annotation.setAnnotationType(newTypeRef(getSarlAction(), type).getType());
			getSarlAction().getAnnotations().add(annotation);
		}
	}
537437
static function getAnnotation($name, $class, $method = NULL, $nullable = TRUE)
	{
		try {
			NULL === $method or $annotation = self::getMethodAnnotation($method, $name, $class);
			isset($annotation) or $annotation = self::getClassAnnotation($class, $name);
		} catch (ReflectionException $e) {
			$annotation = NULL;
		}

		return !$nullable && NULL === $annotation
			? self::annotationClass($name)
			: $annotation;
	}
521194
private function isParseExtendAnnotations(array $annotations, int $type = 1): bool
    {
        foreach ($this->extends as $extend) {
            if ($type == 1) {
                $isParse = $extend->isParseClassAnnotations($annotations);
            } elseif ($type == 2) {
                $isParse = $extend->isParsePropertyAnnotations($annotations);
            } else {
                $isParse = $extend->isParseMethodAnnotations($annotations);
            }
            if ($isParse) {
                return true;
            }
        }

        return false;
    }
1320729
public static function castHandler(HandlerInterface $handler, array $a, Stub $stub, $isNested, $filter = 0)
    {
        // Populate lazy loaded properties
        $a[Caster::PREFIX_PROTECTED . 'fullPath'] = $handler->getFullPath();
        $a[Caster::PREFIX_PROTECTED . 'dirname'] = $handler->getDirname();
        $a[Caster::PREFIX_PROTECTED . 'filename'] = $handler->getFilename();
        $a[Caster::PREFIX_PROTECTED . 'exists'] = $exists = $handler->exists();

        if ($exists) {
            $a[Caster::PREFIX_PROTECTED . 'type'] = $handler->getType();
            $a[Caster::PREFIX_PROTECTED . 'timestamp'] = $handler->getTimestamp();
            $a[Caster::PREFIX_PROTECTED . 'visibility'] = $handler->getVisibility();
        } else {
            unset($a[Caster::PREFIX_PROTECTED . 'type']);
            unset($a[Caster::PREFIX_PROTECTED . 'timestamp']);
            unset($a[Caster::PREFIX_PROTECTED . 'visibility']);
        }

        // Some methods return results instead of setting properties, show these as virtual.
        if ($ext = $handler->getExtension()) {
            $a[Caster::PREFIX_VIRTUAL . 'extension'] = $ext;
        }

        if (!$exists) {
            return $a;
        }

        $a[Caster::PREFIX_VIRTUAL . 'dir'] = $handler->isDir();
        $a[Caster::PREFIX_VIRTUAL . 'file'] = $handler->isFile();
        $a[Caster::PREFIX_VIRTUAL . 'image'] = $handler->isImage();
        $a[Caster::PREFIX_VIRTUAL . 'document'] = $handler->isDocument();
        $a[Caster::PREFIX_VIRTUAL . 'carbon'] = $handler->getCarbon();
        $a[Caster::PREFIX_VIRTUAL . 'public'] = $handler->isPublic();
        $a[Caster::PREFIX_VIRTUAL . 'private'] = $handler->isPrivate();

        return $a;
    }
645923
public function caster($caster = null)
    {
        if ($caster !== null) {
            $this->_caster = $caster;
        }
        return $this->_caster;
    }
1053558
protected void checkProducerMethod(EnhancedAnnotatedMethod<T, ? super X> method) {
        if (method.getEnhancedParameters(Observes.class).size() > 0) {
            throw BeanLogger.LOG.inconsistentAnnotationsOnMethod(PRODUCER_ANNOTATION, "@Observes", this.method,
                    Formats.formatAsStackTraceElement(method.getJavaMember()));
        } else if (method.getEnhancedParameters(ObservesAsync.class).size() > 0) {
            throw BeanLogger.LOG.inconsistentAnnotationsOnMethod(PRODUCER_ANNOTATION, "@ObservesAsync", this.method,
                    Formats.formatAsStackTraceElement(method.getJavaMember()));
        } else if (method.getEnhancedParameters(Disposes.class).size() > 0) {
            throw BeanLogger.LOG.inconsistentAnnotationsOnMethod(PRODUCER_ANNOTATION, "@Disposes", this.method,
                    Formats.formatAsStackTraceElement(method.getJavaMember()));
        } else if (getDeclaringBean() instanceof SessionBean<?> && !Modifier.isStatic(method.slim().getJavaMember().getModifiers())) {
            boolean methodDeclaredOnTypes = false;
            for (Type type : getDeclaringBean().getTypes()) {
                Class<?> clazz = Reflections.getRawType(type);
                try {
                    AccessController.doPrivileged(new GetMethodAction(clazz, method.getName(), method.getParameterTypesAsArray()));
                    methodDeclaredOnTypes = true;
                    break;
                } catch (PrivilegedActionException ignored) {
                }
            }
            if (!methodDeclaredOnTypes) {
                throw BeanLogger.LOG.methodNotBusinessMethod("Producer", this, getDeclaringBean(), Formats.formatAsStackTraceElement(method.getJavaMember()));
            }
        }
    }