Package com.tngtech.archunit.base
Class PackageMatcher
java.lang.Object
com.tngtech.archunit.base.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
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'
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'
PackageMatcher.of(packageIdentifier)
-
Nested Class Summary
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturns a matchingResult
against the provided package name.boolean
static PackageMatcher
Creates a newPackageMatcher
toString()
-
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:
PackageMatcher
to match packages against the supplied literal supporting AspectJ syntax
-
matches
-
match
Returns a matchingResult
against the provided package name. If the package identifier of thisPackageMatcher
does not match the given package name, thenOptional.absent()
is returned.- Parameters:
aPackage
- The package name to match against- Returns:
- A
Result
if the package name matches, otherwiseOptional.absent()
-
toString
-