Example usage for org.springframework.context.annotation FilterType toString

List of usage examples for org.springframework.context.annotation FilterType toString

Introduction

In this page you can find the example usage for org.springframework.context.annotation FilterType toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:org.spring.guice.annotation.GuiceModuleRegistrar.java

private List<TypeFilter> typeFiltersFor(AnnotationAttributes filterAttributes) {

    List<TypeFilter> typeFilters = new ArrayList<TypeFilter>();
    FilterType filterType = filterAttributes.getEnum("type");

    for (Class<?> filterClass : filterAttributes.getClassArray("value")) {
        switch (filterType) {
        case ANNOTATION:
            Assert.isAssignable(Annotation.class, filterClass,
                    "An error occured when processing a @ComponentScan " + "ANNOTATION type filter: ");
            @SuppressWarnings("unchecked")
            Class<Annotation> annoClass = (Class<Annotation>) filterClass;
            typeFilters.add(new AnnotationTypeFilter(annoClass));
            break;
        case ASSIGNABLE_TYPE:
            typeFilters.add(new AssignableTypeFilter(filterClass));
            break;
        case CUSTOM:
            Assert.isAssignable(TypeFilter.class, filterClass,
                    "An error occured when processing a @ComponentScan " + "CUSTOM type filter: ");
            typeFilters.add(BeanUtils.instantiateClass(filterClass, TypeFilter.class));
            break;
        default://from   w  w w .j  av  a 2 s .  c o  m
            throw new IllegalArgumentException("Unknown filter type " + filterType);
        }
    }

    for (String expression : getPatterns(filterAttributes)) {

        String rawName = filterType.toString();

        if ("REGEX".equals(rawName)) {
            typeFilters.add(new RegexPatternTypeFilter(Pattern.compile(expression)));
        } else if ("ASPECTJ".equals(rawName)) {
            typeFilters.add(new AspectJTypeFilter(expression, this.resourceLoader.getClassLoader()));
        } else {
            throw new IllegalArgumentException("Unknown filter type " + filterType);
        }
    }

    return typeFilters;
}