@SuppressWarnings("unchecked")
    private <T> void addClass(Set<Class<? extends T>> classes, 
                         String includeRegExp,
                         String className,
                         Class<T> ofType,
                         Class<? extends Annotation> annotationClass) {
        if (className.matches(includeRegExp)) {
        try {
            Class<?> matchingClass = Class.forName(className);
            matchingClass.asSubclass(ofType);
           
            classes.add((Class<T>) matchingClass);
        } catch (ClassNotFoundException cnfe) {
            throw new IllegalStateException("Scannotation found a class that does not exist " + className + " !", cnfe);
        } catch (ClassCastException cce) {
            throw new IllegalStateException("Class " + className
                    + " is annoted with @"+annotationClass+" but does not extend or implement "+ofType);
        }
        }
    }
@ SuppressWarnings ( "unchecked" ) private < T > void addClass ( Set < Class < ? extends T > > classes , String includeRegExp , String className , Class < T > ofType , Class < ? extends Annotation > annotationClass ) { if ( className . matches ( includeRegExp ) ) { try { Class < ? > matchingClass = Class . forName ( className ) ; matchingClass . asSubclass ( ofType ) ; classes . add ( ( Class < T > ) matchingClass ) ; } catch ( ClassNotFoundException cnfe ) { throw new IllegalStateException ( "Scannotation found a class that does not exist " + className + " !" , cnfe ) ; } catch ( ClassCastException cce ) { throw new IllegalStateException ( "Class " + className + " is annoted with @" + annotationClass + " but does not extend or implement " + ofType ) ; } } }
Created and adds the event to the eventsFound set, if its package matches the includeRegExp.

@param eventBuilderFactory      Event Factory used to create the EventConfig instance with.
@param eventsFound       Set of events found, to add the newly created EventConfig to.
@param includeRegExp     Regular expression to test eventClassName with.
@param eventClassName    Name of the class.