Class JavaPackage
java.lang.Object
org.springframework.modulith.core.JavaPackage
- All Implemented Interfaces:
com.tngtech.archunit.base.DescribedIterable<com.tngtech.archunit.core.domain.JavaClass>
,com.tngtech.archunit.base.HasDescription
,Iterable<com.tngtech.archunit.core.domain.JavaClass>
public class JavaPackage
extends Object
implements com.tngtech.archunit.base.DescribedIterable<com.tngtech.archunit.core.domain.JavaClass>
An abstraction of a Java package.
- Author:
- Oliver Drotbohm
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.tngtech.archunit.base.DescribedIterable
com.tngtech.archunit.base.DescribedIterable.From
-
Method Summary
Modifier and TypeMethodDescriptionboolean
contains
(com.tngtech.archunit.core.domain.JavaClass type) Return whether theJavaPackage
contains the given type.boolean
Returns whether theJavaPackage
contains the type with the given name.boolean
<A extends Annotation>
Optional<A>findAnnotation
(Class<A> annotationType) Finds the annotation of the given type declared on the package itself or any type located the direct package's types .<A extends Annotation>
Optional<A>getAnnotation
(Class<A> annotationType) Return the annotation of the given type declared on the package.Returns all classes residing in the current package and potentially in sub-packages if the current package was created to include them.Returns all direct sub-packages of the current one.Returns the classes exposed by this package, i.e.Returns the local name of the package, i.e.getName()
Returns the name of the package.getSubPackagesAnnotatedWith
(Class<? extends Annotation> annotation) Returns all sub-packages that carry the given annotation type.int
hashCode()
static boolean
isPackageInfoType
(com.tngtech.archunit.core.domain.JavaClass type) Returns whether the given type is thepackage-info.java
one.Iterator<com.tngtech.archunit.core.domain.JavaClass>
iterator()
static JavaPackage
Creates a newJavaPackage
for the given classes and name.Stream<com.tngtech.archunit.core.domain.JavaClass>
stream()
that
(com.tngtech.archunit.base.DescribedPredicate<? super com.tngtech.archunit.core.domain.JavaClass> predicate) Returns allClasses
that match the givenDescribedPredicate
.toSingle()
Reduces theJavaPackage
to only its base package.toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
of
Creates a newJavaPackage
for the given classes and name.- Parameters:
classes
- must not be null.name
- must not be null or empty.- Returns:
-
isPackageInfoType
public static boolean isPackageInfoType(com.tngtech.archunit.core.domain.JavaClass type) Returns whether the given type is thepackage-info.java
one.- Parameters:
type
- must not be null.
-
getName
Returns the name of the package.- Returns:
- will never be null.
-
toSingle
Reduces theJavaPackage
to only its base package.- Returns:
- will never be null.
-
getLocalName
Returns the local name of the package, i.e. the last segment of the qualified package name.- Returns:
- will never be null.
-
getDirectSubPackages
Returns all direct sub-packages of the current one.- Returns:
- will never be null.
-
getClasses
Returns all classes residing in the current package and potentially in sub-packages if the current package was created to include them.- Returns:
- will never be null.
-
getExposedClasses
Returns the classes exposed by this package, i.e. only public ones. Also filters thepackage-info
type.- Returns:
- will never be null.
-
getSubPackagesAnnotatedWith
Returns all sub-packages that carry the given annotation type.- Parameters:
annotation
- must not be null.- Returns:
- will never be null.
-
that
public Classes that(com.tngtech.archunit.base.DescribedPredicate<? super com.tngtech.archunit.core.domain.JavaClass> predicate) Returns allClasses
that match the givenDescribedPredicate
.- Parameters:
predicate
- must not be null.- Returns:
-
contains
public boolean contains(com.tngtech.archunit.core.domain.JavaClass type) Return whether theJavaPackage
contains the given type.- Parameters:
type
- must not be null.
-
contains
Returns whether theJavaPackage
contains the type with the given name.- Parameters:
typeName
- must not be null or empty.
-
stream
- Returns:
- will never be null.
-
getAnnotation
Return the annotation of the given type declared on the package.- Type Parameters:
A
- the annotation type.- Parameters:
annotationType
- the annotation type to be found.- Returns:
- will never be null.
-
findAnnotation
Finds the annotation of the given type declared on the package itself or any type located the direct package's types .- Type Parameters:
A
- the type of the annotation.- Parameters:
annotationType
- must not be null.- Returns:
- will never be null.
- Throws:
IllegalStateException
- in case multiple types in the current package are annotated with the given annotation.- Since:
- 1.2
-
getDescription
- Specified by:
getDescription
in interfacecom.tngtech.archunit.base.HasDescription
-
iterator
-
toString
-
equals
-
hashCode
public int hashCode()
-