Package org.fakereplace.replacement.notification

Examples of org.fakereplace.replacement.notification.ChangedAnnotationImpl


        if (annotations == null) {
            Annotation[] ans = new Annotation[0];
            classAnnotations.put(clazz, ans);
            classAnnotationsByType.put(clazz, Collections.EMPTY_MAP);
            for(Annotation annotation : clazz.getDeclaredAnnotations()) {
                changedClass.changeClassAnnotation(new ChangedAnnotationImpl(null, annotation, ChangeType.REMOVE, changedClass, annotation.annotationType()));
            }
        } else {
            final Class<?> pclass = createAnnotationsProxy(clazz.getClassLoader(), annotations);
            classAnnotations.put(clazz, pclass.getAnnotations());
            Map<Class<? extends Annotation>, Annotation> anVals = new HashMap<Class<? extends Annotation>, Annotation>();
            classAnnotationsByType.put(clazz, anVals);
            int count = 0;
            for (Annotation a : pclass.getAnnotations()) {
                anVals.put(a.annotationType(), a);
                count++;
            }
            final Set<Class<? extends Annotation>> newAnnotations = new HashSet<Class<? extends Annotation>>(anVals.keySet());
            for(Annotation annotation : clazz.getDeclaredAnnotations()) {
                final Annotation newAnnotation = anVals.get(annotation.annotationType());
                if(newAnnotation == null) {
                    //the annotation was removed
                    changedClass.changeClassAnnotation(new ChangedAnnotationImpl(null, annotation, ChangeType.REMOVE, changedClass, annotation.annotationType()));
                } else if(!newAnnotation.equals(annotation)) {
                    //same annotation, but it has been modified
                    changedClass.changeClassAnnotation(new ChangedAnnotationImpl(newAnnotation, annotation, ChangeType.MODIFY, changedClass, annotation.annotationType()));
                }
                newAnnotations.remove(annotation.annotationType());
            }
            for(final Class<? extends Annotation> newAnnotationType : newAnnotations) {
                final Annotation newAnnotation = anVals.get(newAnnotationType);
                changedClass.changeClassAnnotation(new ChangedAnnotationImpl(newAnnotation, null, ChangeType.ADD, changedClass, newAnnotationType));
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.fakereplace.replacement.notification.ChangedAnnotationImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.