Package com.tngtech.archunit.core.domain
Class PackageMatcher
java.lang.Object
com.tngtech.archunit.core.domain.PackageMatcher
Matches packages with a syntax similar to AspectJ. In particular '*' stands for any sequence of
characters but not the dot '.', while '..' stands for any sequence of packages, including zero packages.
For example
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'
'pack.[a.c|b*].d'matches'pack.a.c.d'or'pack.bar.d', but neither'pack.a.d'nor'pack.b.c.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'my.company.some.service.hello.more'and group 1 would be'company', while group 2 would be'hello.more''..service.(a|b*)..'matches'a.service.bar.more'and group 1 would be'bar'
PackageMatcher.of(packageIdentifier)-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionReturns a matchingResultagainst the provided package name.booleanstatic PackageMatcherCreates a newPackageMatchertoString()
-
Field Details
-
TO_GROUPS
-
-
Method Details
-
of
Creates a newPackageMatcher- Parameters:
packageIdentifier- The package literal to match against (e.g.'some*..pk*'-->'somewhere.in.some.pkg')- Returns:
PackageMatcherto match packages against the supplied literal supporting AspectJ syntax
-
matches
-
match
Returns a matchingResultagainst the provided package name. If the package identifier of thisPackageMatcherdoes not match the given package name, thenOptional.empty()is returned.- Parameters:
aPackage- The package name to match against- Returns:
- A
Resultif the package name matches, otherwiseOptional.empty()
-
toString
-