Class PackageName
java.lang.Object
org.springframework.modulith.core.PackageName
- All Implemented Interfaces:
Comparable<PackageName>
The name of a Java package. Packages are sortable comparing their individual segments and deeper packages sorted
last.
- Since:
- 1.2
- Author:
- Oliver Drotbohm
-
Method Summary
Modifier and TypeMethodDescription(package private) StringasFilter(boolean includeNested) Returns the filter expression to include all types including from nested packages.int(package private) booleancontains(PackageName reference) Returns whether the package name contains the given one, i.e. if the given one either is the current one or a sub-package of it.boolean(package private) Stream<PackageName>expandUntil(PackageName reference) Returns the names of sub-packages of the current one until the given referencePackageName.(package private) StringReturns the last segment of a package name.(package private) StringgetLocalName(String base) Returns the nested name in reference to the given base.(package private) StringgetName()Returns the raw name.(package private) PackageNameReturns the parentPackageName.inthashCode()(package private) booleanReturns whether thePackageNamehas the givenStringname.(package private) booleanReturns whether the currentPackageNamehas a parent.(package private) booleanisDirectParentOf(PackageName reference) (package private) booleanisEmpty()(package private) booleanisParentPackageOf(PackageName reference) Returns whether the currentPackageNameis the name of a parent package of the given one.(package private) booleanisSubPackageOf(PackageName reference) Returns whether the currentPackageNameis the name of a sub-package with the given name.(package private) intlength()Returns the length of the package name.(package private) booleannameContainsOrMatches(String candidate) Returns whether the package name contains a segment with the given candidate or matches the given expression entirely.(package private) static PackageNameReturns thePackageNamewith the given name.(package private) static PackageNameReturns thePackageNamefor the given segments.(package private) static PackageNameCreates a newPackageNamefor the given fully-qualified type name.toString()
-
Method Details
-
ofType
Creates a newPackageNamefor the given fully-qualified type name.- Parameters:
fullyQualifiedName- must not be null or empty.- Returns:
- will never be null.
-
of
Returns thePackageNamewith the given name.- Parameters:
name- must not be null.- Returns:
- will never be null.
- Since:
- 1.4
-
of
Returns thePackageNamefor the given segments.- Parameters:
segments- must not be null.- Returns:
- will never be null.
- Since:
- 1.4
-
length
int length()Returns the length of the package name.- Returns:
- will never be null.
-
getName
String getName()Returns the raw name.- Returns:
- will never be null.
-
hasName
Returns whether thePackageNamehas the givenStringname.- Parameters:
name- must not be null or empty.
-
getLocalName
String getLocalName()Returns the last segment of a package name.- Returns:
- will never be null.
-
getLocalName
Returns the nested name in reference to the given base.- Parameters:
base- must not be null or empty.- Returns:
- will never be null.
-
asFilter
Returns the filter expression to include all types including from nested packages.- Returns:
- will never be null.
-
isParentPackageOf
Returns whether the currentPackageNameis the name of a parent package of the given one.- Parameters:
reference- must not be null.- Returns:
- will never be null.
-
isDirectParentOf
-
contains
Returns whether the package name contains the given one, i.e. if the given one either is the current one or a sub-package of it.- Parameters:
reference- must not be null.
-
isSubPackageOf
Returns whether the currentPackageNameis the name of a sub-package with the given name.- Parameters:
reference- must not be null.- Returns:
- will never be null.
-
isEmpty
boolean isEmpty() -
nameContainsOrMatches
Returns whether the package name contains a segment with the given candidate or matches the given expression entirely. The latter is tested for if the expression contains a dot, indicating a multi-package match is requested. Expressions generally support single character (?) and multi-character (*) wildcards.- Parameters:
candidate- must not be null or empty.- Since:
- 1.4
-
compareTo
- Specified by:
compareToin interfaceComparable<PackageName>
-
expandUntil
Returns the names of sub-packages of the current one until the given referencePackageName.- Parameters:
reference- must not be null.- Returns:
- will never be null.
- Since:
- 1.4
-
hasParent
boolean hasParent()Returns whether the currentPackageNamehas a parent.- Since:
- 1.4
-
getParent
Returns the parentPackageName.- Returns:
- can be null.
- Since:
- 1.4
-
toString
-
equals
-
hashCode
public int hashCode()
-