Java 类javax.enterprise.inject.Stereotype 实例源码

项目:deltaspike    文件:DefaultViewConfigInheritanceStrategy.java   
protected void addViewMetaData(Annotation currentAnnotation, List<Annotation> metaDataList)
{
    Class<? extends Annotation> annotationClass = currentAnnotation.annotationType();

    if (annotationClass.isAnnotationPresent(ViewMetaData.class))
    {
        metaDataList.add(currentAnnotation);
    }

    if (annotationClass.isAnnotationPresent(Stereotype.class))
    {
        for (Annotation inheritedViaStereotype : annotationClass.getAnnotations())
        {
            if (inheritedViaStereotype.annotationType().isAnnotationPresent(ViewMetaData.class))
            {
                metaDataList.add(inheritedViaStereotype);
            }
        }
    }
}
项目:reactive-cdi-events    文件:ReactorObserverRegistry.java   
static Set<Annotation> findQualifiers(Set<Annotation> annotations) {
    Set<Annotation> results = new LinkedHashSet<>();
    for(Annotation annotation : annotations) {
        Class<? extends Annotation> annotationClass = annotation.getClass();
        if(annotation instanceof Default) {
            continue;
        } else if(annotationClass.getAnnotation(Qualifier.class) != null) {
            results.add(annotation);
        } else if(annotationClass.getAnnotation(Stereotype.class) != null) {
            Set<Annotation> parentAnnotations = new LinkedHashSet<>(asList(annotationClass.getAnnotations()));
            results.addAll(findQualifiers(parentAnnotations));
        }
    }
    return results;
}
项目:java-restify    文件:RestifyProxyCdiBean.java   
@Override
public Set<Class<? extends Annotation>> getStereotypes() {
    Set<Class<? extends Annotation>> stereotypes = new HashSet<>();

    Arrays.stream(javaType.getAnnotations())
        .map(a -> a.getClass())
            .filter(a -> a.getAnnotation(Stereotype.class) != null)
                .forEach(stereotypes::add);

    return stereotypes;
}
项目:fmek    文件:InterceptorInfoVisitor.java   
public static boolean isStereotype(Class<? extends Annotation> candidate) {
    for (Annotation annotation : candidate.getAnnotations()) {
        if (annotation.annotationType().equals(Stereotype.class)) {
            return true;
        }
    }
    return false;
}
项目:javaee-samples    文件:BeanUtils.java   
private static <T extends Annotation> T hasAnnotationInStereotypes(Annotation[] declaredAnnotations,
                                                                   Class<T> expectedAnnotationType) {
    for (Annotation declaredAnnotation : declaredAnnotations) {
        Class<? extends Annotation> declaredAnnotationType = declaredAnnotation.annotationType();
        if (declaredAnnotationType == expectedAnnotationType) {
            return expectedAnnotationType.cast(declaredAnnotation);
        } else if (declaredAnnotationType.isAnnotationPresent(Stereotype.class)) {
            T ann = hasAnnotationInStereotypes(declaredAnnotationType.getAnnotations(), expectedAnnotationType);
            if (ann != null) {
                return expectedAnnotationType.cast(ann);
            }
        }
    }
    return null;
}
项目:lettuce-core    文件:AbstractCdiBean.java   
@Override
public Set<Class<? extends Annotation>> getStereotypes() {
    Set<Class<? extends Annotation>> stereotypes = new HashSet<>();

    for (Annotation annotation : getQualifiers()) {
        Class<? extends Annotation> annotationType = annotation.annotationType();
        if (annotationType.isAnnotationPresent(Stereotype.class)) {
            stereotypes.add(annotationType);
        }
    }

    return stereotypes;
}
项目:deltaspike    文件:SecurityUtils.java   
public static Annotation resolveSecurityBindingType(Annotation annotation)
{
    List<Annotation> result = getAllAnnotations(annotation.annotationType().getAnnotations(),
        new HashSet<Integer>());

    for (Annotation foundAnnotation : result)
    {
        if (foundAnnotation.annotationType().isAnnotationPresent(SecurityBindingType.class))
        {
            return foundAnnotation;
        }
    }
    throw new IllegalStateException(annotation.annotationType().getName() + " is a " + Stereotype.class.getName() +
            " but it isn't annotated with " + SecurityBindingType.class.getName());
}
项目:deltaspike    文件:DefaultConfigNodeConverter.java   
private List<Annotation> mergeMetaData(Set<Annotation> metaData, List<Annotation> inheritedMetaData)
{
    //TODO add qualifier support
    List<Annotation> nodeViewMetaData = new ArrayList<Annotation>();
    List<Annotation> viewMetaDataFromStereotype = new ArrayList<Annotation>();

    for (Annotation annotation : metaData)
    {
        if (annotation.annotationType().isAnnotationPresent(ViewMetaData.class))
        {
            nodeViewMetaData.add(annotation);
        }

        //TODO move to stereotype-util, improve it and merge it with DefaultViewConfigInheritanceStrategy
        if (annotation.annotationType().isAnnotationPresent(Stereotype.class))
        {
            for (Annotation metaAnnotation : annotation.annotationType().getAnnotations())
            {
                if (metaAnnotation.annotationType().isAnnotationPresent(ViewMetaData.class))
                {
                    viewMetaDataFromStereotype.add(metaAnnotation);
                }
            }
        }
    }

    //merge meta-data of same level
    List<Annotation> result = mergeAnnotationInstances(viewMetaDataFromStereotype, nodeViewMetaData);

    if (inheritedMetaData != null && !inheritedMetaData.isEmpty())
    {
        //merge meta-data with levels above
        result = mergeAnnotationInstances(inheritedMetaData, result);
    }

    return result;
}
项目:winter-data-jpa    文件:SimpleRepositoryBean.java   
public Set<Class<? extends Annotation>> getStereotypes() {
    return Stream.of(repositoryType.getAnnotations())
            .map(a -> a.annotationType())
            .filter(a -> a.isAnnotationPresent(Stereotype.class))
            .collect(Collectors.toSet());
}