call all annotation methods required
@param Controller $class
@param array $annotation
@param string $type
@param string $annotationType
@throws MissingMethodException
@access  protected
@since   3.0
@package Gcs\Framework\Core\Engine
340006
protected function _callAnnotation(Controller &$class, $annotation = [], $type = 'class', $annotationType = 'Before') {
        foreach ($annotation[$type] as $action => $annotationClasses) {
            foreach ($annotationClasses as $annotationClass) {
                if ($annotationClass['annotation'] == $annotationType) {
                    /** @var \Gcs\Framework\Core\Annotation\Annotations\Common\Before $instance */
                    $instance = $annotationClass['instance'];

                    $className = $instance->class;
                    $methodName = $instance->method;

                    if (method_exists($className, $methodName)) {
                        if ($className == get_class($class)) {
                            $class->$methodName();
                        }
                        else {
                            $reflectionMethod = new \ReflectionMethod($className, $methodName);
                            echo $reflectionMethod->invoke(new $className());
                        }
                    }
                    else {
                        throw new MissingMethodException('The method "' . $methodName . '" from the class "' . $className . '" does not exist');
                    }
                }
            }
        }
    }
1132428
private function implementJsonSerialize(Type $type, ClassGenerator $class)
    {
        $methodName = 'jsonSerialize';
        $class->removeMethod($methodName);
        $class->addMethodFromGenerator(
            MethodGenerator::fromArray([
                'name' => $methodName,
                'parameters' => [],
                'visibility' => MethodGenerator::VISIBILITY_PUBLIC,
                'body' => $this->generateJsonSerializeBody($type, $class),
                'docblock' => DocBlockGeneratorFactory::fromArray([
                    'tags' => [
                        [
                            'name' => 'return',
                            'description' => 'array'
                        ]
                    ]
                ])
            ])
        );
    }
1234231
public function resolve($annotation, $reflectionClass, $pack)
    {
        $app = $this->app;


        $snakeClass = implode('_',preg_split('/(?=[A-Z])/', $reflectionClass->getShortName(), -1, PREG_SPLIT_NO_EMPTY));
        $controllerKey = implode('.',[$pack->getPackName(),'controller', strtolower($snakeClass)]);
        $controller = $reflectionClass->getShortName();

        $app[$controllerKey] = function () use ($app, $reflectionClass, $pack) {
            $class = $reflectionClass->getName();

            return new $class($app, $pack);
        };

        $$controller = $app['controllers_factory'];

        $this->registerControllerFilters($$controller, $controllerKey,  $annotation->filters);
        $this->registerRoutes($$controller, $controllerKey, $reflectionClass);

        $routePattern = ($annotation->mount != '')  ? $pack->getPackName().'/'.$annotation->mount : $pack->getPackName().'/'.strtolower($snakeClass);

        $this->app['controllers']->mount($routePattern, $$controller);

    }
203495
protected function setParam(array $data, $name, $required = true, $type = 'string')
    {
        if (!isset($data[$name]) || ($required && gettype($data[$name]) !== $type)) {
            throw new Exception\DomainException(
                sprintf(
                    '%s expects the annotation %s parameter to define a %s; received "%s"',
                    get_class($this),
                    $name,
                    $type,
                    gettype($data[$name])
                )
            );
        }

        $this->$name = $data[$name];
    }
898568
protected function handleDataControl(RelationshipAnnotation $annotation, Relationship $relationship)
    {
        $relationship->setIncludeData($annotation->dataAllowed);
        $relationship->setDataLimit($annotation->dataLimit);
    }
760047
@Override
    public <A extends Annotation> A getAnnotation(Class<A> annotationClass) {
        return method.getAnnotation(annotationClass);
    }
157633
public static List<Method> getAllAnnotationPresentMethod(Class<?> type,
                                                             Class<? extends Annotation> annotation) {
        List<Method> methods = getAllMethod(type);

        if (methods.isEmpty()) {
            return Collections.emptyList();
        }

        return methods.stream().filter(method -> method.isAnnotationPresent(annotation))
            .collect(Collectors.toList());
    }
1122353
public void addStartSagaAnnotation(final Class<? extends Annotation> annotationClass) {
        Objects.requireNonNull(annotationClass, "The type of annotation is not allowed to be null");
        startSagaAnnotations.add(annotationClass);
    }
264078
public function processController($name, AnnotationCollection $annotations)
    {
        $this->controllerName = $name;

        $this->baseName = null;

        foreach ($annotations as $annotation) {
            if ($annotation instanceof Annotation\Base) {
                $this->baseName = $annotation->getName();
            }
        }
    }
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;
    }
391881
private function unknownParameterException(\ReflectionFunctionAbstract $controller, RequestParam $annotation) : HttpInternalServerErrorException
    {
        return new HttpInternalServerErrorException(sprintf(
            '%s() does not have a $%s parameter, please check your annotation.',
            $this->reflectionTools->getFunctionName($controller),
            $annotation->getBindTo()
        ));
    }
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;
    }
915544
private void callAnnotatedMethod(final Class<? extends Annotation> annotationClass) {
        if (this.lifecycleMethod.get(annotationClass.getName()) != null) {
            for (final Method method : this.lifecycleMethod.get(annotationClass.getName())) {

                try {
                    ClassUtility.callMethod(method, this);
                } catch (final CoreException e) {
                    LOGGER.error(CALL_ANNOTATED_METHOD_ERROR, e);
                }
            }
        }
    }
314881
private function parseClassAnnotations(string $className, array $annotation, array $classAnnotations)
    {
        foreach ($classAnnotations as $classAnnotation) {
            $annotationClassName = get_class($classAnnotation);
            $classNameTmp        = str_replace('\\', '/', $annotationClassName);
            $classFileName       = basename($classNameTmp);
            $beanNamespaceTmp    = dirname($classNameTmp, 2);
            $beanNamespace       = str_replace('/', '\\', $beanNamespaceTmp);

            $annotationWrapperClassName = "{$beanNamespace}\\Wrapper\\{$classFileName}Wrapper";

            if (!class_exists($annotationWrapperClassName)) {
                continue;
            }

            /* @var WrapperInterface $wrapper */
            $wrapper = new $annotationWrapperClassName($this);

            // wrapper extend
            foreach ($this->componentNamespaces as $componentNamespace) {
                $annotationWrapperExtendClassName = "{$componentNamespace}\\Bean\\Wrapper\\Extend\\{$classFileName}Extend";
                if (!class_exists($annotationWrapperExtendClassName)) {
                    continue;
                }
                $extend = new $annotationWrapperExtendClassName();
                $wrapper->addExtends($extend);
            }

            $objectDefinitionAry = $wrapper->doWrapper($className, $annotation);
            if ($objectDefinitionAry != null) {
                list($beanName, $objectDefinition) = $objectDefinitionAry;
                $this->definitions[$beanName] = $objectDefinition;
            }
        }
    }
1158008
private function invalidArrayParameterException(\ReflectionFunctionAbstract $controller, RequestParam $annotation) : HttpBadRequestException
    {
        return new HttpBadRequestException(sprintf(
            '%s() expects an array for %s parameter "%s" (bound to $%s), string given.',
            $this->reflectionTools->getFunctionName($controller),
            $annotation->getParameterType(),
            $annotation->getName(),
            $annotation->getBindTo()
        ));
    }
100642
protected function initializeActionMethodValidators()
    {
        $this->initializeActionMethodValidatorsParent();

        $request = $this->getRequest();

        if (false === $request->hasArgument('name')) {
            throw MissingArgumentException::ajaxControllerNameArgumentNotSet();
        }

        if (false === $request->hasArgument('className')) {
            throw MissingArgumentException::ajaxControllerClassNameArgumentNotSet();
        }

        $className = $request->getArgument('className');

        if (false === class_exists($className)) {
            throw ClassNotFoundException::ajaxControllerFormClassNameNotFound($className);
        }

        if (false === in_array(FormInterface::class, class_implements($className))) {
            throw InvalidArgumentTypeException::ajaxControllerWrongFormType($className);
        }

        $this->arguments->addNewArgument($request->getArgument('name'), $className, true);
    }
1133873
public static void process(@NonNull Document textDocument, AnnotatableType... annotationTypes) {
      if (annotationTypes == null || annotationTypes.length == 0) {
         return;
      }

      for (AnnotatableType annotationType : annotationTypes) {
         if (annotationType == null) {
            continue;
         }

         if (textDocument.getAnnotationSet().isCompleted(annotationType)) {
            continue;
         }

         if (log.isLoggable(Level.FINEST)) {
            log.finest("Annotating for {0}", annotationType);
         }

         Annotator annotator = AnnotatorCache.getInstance().get(annotationType, textDocument.getLanguage());

         if (annotator == null) {
            throw new IllegalStateException("Could not get annotator for " + annotationType);
         }

         if (!annotator.satisfies().contains(annotationType)) {
            throw new IllegalStateException(annotator.getClass().getName() + " does not satisfy " + annotationType);
         }

         //Get the requirements out of the way
         for (AnnotatableType prereq : annotator.requires()) {
            process(textDocument, prereq);
         }

         annotator.annotate(textDocument);
         for (AnnotatableType type : annotator.satisfies()) {
            textDocument
               .getAnnotationSet()
               .setIsCompleted(type, true, annotator.getClass().getName() + "::" + annotator.getVersion());
         }

      }
   }