Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source
   * Copyright 2008, Red Hat, Inc., and individual contributors
   * by the @authors tag. See the copyright.txt in the distribution for a
   * full listing of individual contributors.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
  * http://www.apache.org/licenses/LICENSE-2.0
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 package org.jboss.weld.metadata.cache;
 
 import static java.lang.annotation.ElementType.FIELD;
 import static java.lang.annotation.ElementType.METHOD;
 import static java.lang.annotation.ElementType.TYPE;
 
 import java.util.Set;
 
 
A meta model for a stereotype, allows us to cache a stereotype and to validate it

Author(s):
Pete Muir
 
 public class StereotypeModel<T extends Annotationextends AnnotationModel<T> {
     private static final Set<Class<? extends Annotation>> META_ANNOTATIONS = Collections.<Class<? extends Annotation>>singleton(Stereotype.class);
 
     // Is the stereotype an alternative
     private boolean alternative;
     // The default scope type
     private Annotation defaultScopeType;
     // Is the bean name defaulted
     private boolean beanNameDefaulted;
     // The interceptor bindings
     private Set<AnnotationinterceptorBindings;
 
     private Set<AnnotationinheritedStereotypes;
 
     private Set<AnnotationmetaAnnotations;

    
Constructor
 
     public StereotypeModel(EnhancedAnnotation<T> enhancedAnnotatedAnnotation) {
         super(enhancedAnnotatedAnnotation);
     }
 
     @Override
     protected void init(EnhancedAnnotation<T> annotatedAnnotation) {
         super.init(annotatedAnnotation);
         initAlternative(annotatedAnnotation);
         initDefaultScopeType(annotatedAnnotation);
         initBeanNameDefaulted(annotatedAnnotation);
         initInterceptorBindings(annotatedAnnotation);
         initInheritedStereotypes(annotatedAnnotation);
         checkBindings(annotatedAnnotation);
         this. = annotatedAnnotation.getAnnotations();
     }



    
Validates the binding types
 
     private void checkBindings(EnhancedAnnotation<T> annotatedAnnotation) {
         Set<Annotationbindings = annotatedAnnotation.getMetaAnnotations(Qualifier.class);
         if (bindings.size() > 0) {
             for (Annotation annotation : bindings) {
                 if (!annotation.annotationType().equals(Named.class)) {
                     throw ..qualifierOnStereotype(annotatedAnnotation);
                 }
             }
         }
     }

    
Initializes the interceptor bindings
    private void initInterceptorBindings(EnhancedAnnotation<T> annotatedAnnotation) {
         = annotatedAnnotation.getMetaAnnotations(InterceptorBinding.class);
    }
    private void initInheritedStereotypes(EnhancedAnnotation<T> annotatedAnnotation) {
        this. = annotatedAnnotation.getMetaAnnotations(Stereotype.class);
    }

    
Initializes the bean name defaulted
    private void initBeanNameDefaulted(EnhancedAnnotation<T> annotatedAnnotation) {
        if (annotatedAnnotation.isAnnotationPresent(Named.class)) {
            if (!"".equals(annotatedAnnotation.getAnnotation(Named.class).value())) {
                throw ..valueOnNamedStereotype(annotatedAnnotation);
            }
             = true;
        }
    }

    
Initializes the default scope type
    private void initDefaultScopeType(EnhancedAnnotation<T> annotatedAnnotation) {
        Set<AnnotationscopeTypes = new HashSet<Annotation>();
        scopeTypes.addAll(annotatedAnnotation.getMetaAnnotations(Scope.class));
        scopeTypes.addAll(annotatedAnnotation.getMetaAnnotations(NormalScope.class));
        if (scopeTypes.size() > 1) {
            throw ..multipleScopes(annotatedAnnotation);
        } else if (scopeTypes.size() == 1) {
            this. = scopeTypes.iterator().next();
        }
    }

    
Initializes the default deployment type
    private void initAlternative(EnhancedAnnotation<T> annotatedAnnotation) {
        if (annotatedAnnotation.isAnnotationPresent(Alternative.class)) {
            this. = true;
        }
    }
    @Override
    protected void check(EnhancedAnnotation<T> annotatedAnnotation) {
        super.check(annotatedAnnotation);
        if (isValid()) {
            if (!annotatedAnnotation.isAnnotationPresent(Target.class)) {
                ..missingTarget(annotatedAnnotation);
            } else {
                ElementType[] elementTypes = annotatedAnnotation.getAnnotation(Target.class).value();
                if (!(Arrays2.unorderedEquals(elementTypes) ||
                                Arrays2.unorderedEquals(elementTypes) ||
                                Arrays2.unorderedEquals(elementTypes) ||
                                Arrays2.unorderedEquals(elementTypes) ||
                                Arrays2.unorderedEquals(elementTypes)
                )) {
                }
            }
        }
    }


    
Get the default scope type the stereotype specifies

Returns:
The default scope type, or null if none is specified
    public Annotation getDefaultScopeType() {
        return ;
    }

    
Get any interceptor bindings the the stereotype specifies

Returns:
The interceptor bindings, or an empty set if none are specified.
        return ;
    }

    
Indicates if the bean name is defaulted

Returns:
True if defaulted, false otherwise
    public boolean isBeanNameDefaulted() {
        return ;
    }

    
Gets the meta-annotation type

Returns:
The Stereotype class
    @Override
    protected Set<Class<? extends Annotation>> getMetaAnnotationTypes() {
        return ;
    }

    

Returns:
    public boolean isAlternative() {
        return ;
    }
        return ;
    }

    

Returns:
the metaAnnotations
    public Set<AnnotationgetMetaAnnotations() {
        return ;
    }
New to GrepCode? Check out our FAQ X