Class FilterBuilder

  • All Implemented Interfaces:
    Predicate<String>

    public class FilterBuilder
    extends Object
    implements Predicate<String>
    Builds include/exclude filters for Reflections.

    For example:

     Predicate filter1 = FilterBuilder.parsePackages("-java, "-javax");
     Predicate filter2 = new FilterBuilder().include(".*").exclude("java.*");
     
    • Constructor Detail

      • FilterBuilder

        public FilterBuilder()
    • Method Detail

      • includePackage

        public FilterBuilder includePackage​(Class<?> aClass)
        include a package of a given class
      • excludePackage

        public FilterBuilder excludePackage​(Class<?> aClass)
        exclude a package of a given class
      • includePackage

        public FilterBuilder includePackage​(String... prefixes)
        include packages of given prefixes
      • excludePackage

        public FilterBuilder excludePackage​(String prefix)
        exclude a package of a given prefix
      • prefix

        public static String prefix​(String qualifiedName)
      • parse

        public static FilterBuilder parse​(String includeExcludeString)
        Parses a string representation of an include/exclude filter.

        The given includeExcludeString is a comma separated list of regexes, each starting with either + or - to indicate include/exclude.

        For example parsePackages("-java\\..*, -javax\\..*, -sun\\..*, -com\\.sun\\..*") or parse("+com\\.myn\\..*,-com\\.myn\\.excluded\\..*"). Note that "-java\\..*" will block "java.foo" but not "javax.foo".

        See also the more useful parsePackages(String) method.

      • parsePackages

        public static FilterBuilder parsePackages​(String includeExcludeString)
        Parses a string representation of an include/exclude filter.

        The given includeExcludeString is a comma separated list of package name segments, each starting with either + or - to indicate include/exclude.

        For example parsePackages("-java, -javax, -sun, -com.sun") or parse("+com.myn,-com.myn.excluded"). Note that "-java" will block "java.foo" but not "javax.foo".

        The input strings "-java" and "-java." are equivalent.