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 java.util.Set;
 
 

Author(s):
Marius Bogoevici
 
 public class InterceptorBindingModel<T extends Annotationextends AbstractBindingModel<T> {
     private static final Set<Class<? extends Annotation>> META_ANNOTATIONS = Collections.<Class<? extends Annotation>> singleton(InterceptorBinding.class);
     private Set<AnnotationmetaAnnotations;
 
     public InterceptorBindingModel(EnhancedAnnotation<T> enhancedAnnotatedAnnotation) {
         super(enhancedAnnotatedAnnotation);
     }
 
     @Override
     protected void init(EnhancedAnnotation<T> annotatedAnnotation) {
         super.init(annotatedAnnotation);
         if (isValid()) {
             initInterceptionBindingTypes(annotatedAnnotation);
             checkArrayAndAnnotationValuedMembers(annotatedAnnotation);
             checkMetaAnnotations(annotatedAnnotation);
             this. = annotatedAnnotation.getAnnotations();
         }
     }
 
     @Override
     protected Set<Class<? extends Annotation>> getMetaAnnotationTypes() {
         return ;
     }
 
     public Set<AnnotationgetMetaAnnotations() {
         return ;
     }
 
     protected void initInterceptionBindingTypes(EnhancedAnnotation<T> annotatedAnnotation) {
          = annotatedAnnotation.getMetaAnnotations(InterceptorBinding.class);
     }
 
     protected void check(EnhancedAnnotation<T> annotatedAnnotation) {
         super.check(annotatedAnnotation);
         if (isValid()) {
             if (!annotatedAnnotation.isAnnotationPresent(Target.class)) {
                 ..missingTarget(annotatedAnnotation);
             }
             if (!isValidTargetType(annotatedAnnotation)) {
                 ..missingTargetTypeMethodOrTargetType(annotatedAnnotation);
             }
         }
     }
 
     private static boolean isValidTargetType(EnhancedAnnotation<?> annotation) {
         Target target = annotation.getAnnotation(Target.class);
         return target != null
                 && (Arrays2.unorderedEquals(target.value(), ..) || Arrays2.unorderedEquals(target.value(), .));
     }
 
     private void checkMetaAnnotations(EnhancedAnnotation<T> annotatedAnnotation) {
         ElementType[] elementTypes = getTargetElementTypes(annotatedAnnotation.getAnnotation(Target.class));
         for (Annotation inheritedBinding : getInheritedInterceptionBindingTypes()) {
             ElementType[] metaAnnotationElementTypes = getTargetElementTypes(inheritedBinding.annotationType().getAnnotation(Target.class));
             if (!Arrays2.containsAll(metaAnnotationElementTypeselementTypes)) {
                ..invalidInterceptorBindingTargetDeclaration(inheritedBinding.annotationType().getName(),
                        Arrays.toString(metaAnnotationElementTypes), annotatedAnnotation.getJavaClass().getName(), Arrays.toString(elementTypes));
            }
        }
    }
    private ElementType[] getTargetElementTypes(Target target) {
        if (target == null) {
            return ElementType.values();
        }
        return target.value();
    }
    private void checkArrayAndAnnotationValuedMembers(EnhancedAnnotation<T> annotatedAnnotation) {
        for (EnhancedAnnotatedMethod<?, ?> annotatedMethod : annotatedAnnotation.getMembers()) {
            if ((Reflections.isArrayType(annotatedMethod.getJavaClass()) || Annotation.class.isAssignableFrom(annotatedMethod.getJavaClass()))
                    && !getNonBindingMembers().contains(annotatedMethod.slim())) {
                throw ..nonBindingMemberTypeException(annotatedMethod);
            }
        }
    }

    
Retrieves the transitive interceptor binding types that are inherited by this interceptor binding, as per section 9.1.1 of the specification, "Interceptor binding types with additional interceptor bindings"

Returns:
a set of transitive interceptor bindings, if any
        return ;
    }
    public boolean isEqual(Annotation instanceAnnotation other) {
        return isEqual(instanceotherfalse);
    }
    public boolean isEqual(Annotation instanceAnnotation otherboolean includeNonBindingTypes) {
        if (instance.annotationType().equals(getRawType()) && other.annotationType().equals(getRawType())) {
            for (AnnotatedMethod<?> annotatedMethod : getAnnotatedAnnotation().getMethods()) {
                if (includeNonBindingTypes || !getNonBindingMembers().contains(annotatedMethod)) {
                    try {
                        AccessController.doPrivileged(SetAccessibleAction.of(annotatedMethod.getJavaMember()));
                        Object thisValue = annotatedMethod.getJavaMember().invoke(instance);
                        Object thatValue = annotatedMethod.getJavaMember().invoke(other);
                        if (!thisValue.equals(thatValue)) {
                            return false;
                        }
                    } catch (IllegalArgumentException e) {
                        throw new WeldException(e);
                    } catch (IllegalAccessException e) {
                        throw new WeldException(e);
                    } catch (InvocationTargetException e) {
                        throw new WeldException(e);
                    }
                }
            }
            return true;
        }
        return false;
    }
New to GrepCode? Check out our FAQ X