Package com.tngtech.archunit.base
Class PackageMatcher
java.lang.Object
com.tngtech.archunit.base.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
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
Nested Classes Modifier and Type Class Description static class
PackageMatcher.Result
-
Field Summary
Fields 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 matchingResult
against the provided package name.boolean
matches(java.lang.String aPackage)
static PackageMatcher
of(java.lang.String packageIdentifier)
Creates a newPackageMatcher
java.lang.String
toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Field Details
-
TO_GROUPS
@PublicAPI(usage=ACCESS) public static final Function<PackageMatcher.Result,java.util.List<java.lang.String>> 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
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-