Class PackageMatcher


public final class PackageMatcher
extends java.lang.Object
Matches packages with a syntax similar to AspectJ. In particular '*' stands for any sequence of characters, '..' stands for any sequence of packages, including zero packages.
For example
  • '..pack..' matches 'a.pack', 'a.pack.b' or 'a.b.pack.c.d', but not 'a.packa.b'
  • '*.pack.*' matches 'a.pack.b', but not 'a.b.pack.c'
  • '..*pack*..' matches 'a.prepackfix.b'
  • '*.*.pack*..' matches 'a.b.packfix.c.d', but neither 'a.packfix.b' nor 'a.b.prepack.d'
Furthermore the use of capturing groups is supported. In this case '(*)' matches any sequence of characters, but not the dot '.', while '(**)' matches any sequence including the dot.
For example
  • '..service.(*)..' matches 'a.service.hello.b' and group 1 would be 'hello'
  • '..service.(**)' matches 'a.service.hello.more' and group 1 would be 'hello.more'
  • 'my.(*)..service.(**)' matches '' and group 1 would be 'company', while group 2 would be 'hello.more'
Create via PackageMatcher.of(packageIdentifier)
  • Nested Class Summary

    Nested Classes
    Modifier and Type Class Description
    static class  PackageMatcher.Result  
  • Field Summary

    Modifier and Type Field Description
    static Function<PackageMatcher.Result,​java.util.List<java.lang.String>> TO_GROUPS  
  • Method Summary

    Modifier and Type Method Description
    Optional<PackageMatcher.Result> match​(java.lang.String aPackage)
    Returns a matching Result against the provided package name.
    boolean matches​(java.lang.String aPackage)  
    static PackageMatcher of​(java.lang.String packageIdentifier)
    Creates a new PackageMatcher
    java.lang.String toString()  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait