@Internal public class ApiSurface extends java.lang.Object
For the purposes of calculating the public API surface, exposure includes any public or protected occurrence of:
Exposure is a transitive property. The resulting map excludes primitives and array classes themselves.
It is prudent (though not required) to prune prefixes like "java" via the builder method
pruningPrefix(java.lang.String)
to halt the traversal so it does not uselessly catalog references that are
not interesting.
Modifier and Type | Method and Description |
---|---|
static org.hamcrest.Matcher<java.lang.Class<?>> |
classesInPackage(java.lang.String packageName)
A factory method to create a
Class matcher for classes residing in a given package. |
static org.hamcrest.Matcher<ApiSurface> |
containsOnlyClassesMatching(org.hamcrest.Matcher<java.lang.Class<?>>... classMatchers)
|
static org.hamcrest.Matcher<ApiSurface> |
containsOnlyClassesMatching(java.util.Set<org.hamcrest.Matcher<java.lang.Class<?>>> classMatchers)
A factory method to create an
ApiSurface matcher, producing a positive match if the
queried api surface contains ONLY classes described by the provided matchers. |
static org.hamcrest.Matcher<ApiSurface> |
containsOnlyPackages(java.util.Set<java.lang.String> packageNames)
A factory method to create an
ApiSurface matcher, producing a positive match if the
queried api surface contains classes ONLY from specified package names. |
static org.hamcrest.Matcher<ApiSurface> |
containsOnlyPackages(java.lang.String... packageNames)
|
static ApiSurface |
empty()
Returns an empty
ApiSurface . |
java.util.List<java.lang.Class<?>> |
getAnyExposurePath(java.lang.Class<?> exposedClass)
Returns a path from an exposed class to a root class.
|
java.util.Set<java.lang.Class<?>> |
getExposedClasses()
Returns exposed types in this set, including arrays and primitives as specified.
|
java.util.Set<java.lang.Class<?>> |
getRootClasses()
Returns all public classes originally belonging to the package in the
ApiSurface . |
ApiSurface |
includingClass(java.lang.Class<?> clazz)
Returns an
ApiSurface like this one, but also including the given class. |
ApiSurface |
includingPackage(java.lang.String packageName,
java.lang.ClassLoader classLoader)
Returns an
ApiSurface like this one, but also including the named package and all of
its subpackages. |
static ApiSurface |
ofClass(java.lang.Class<?> clazz)
Returns an
ApiSurface object representing just the surface of the given class. |
static ApiSurface |
ofPackage(java.lang.Package aPackage,
java.lang.ClassLoader classLoader)
Returns an
ApiSurface object representing the given package and all subpackages. |
static ApiSurface |
ofPackage(java.lang.String packageName,
java.lang.ClassLoader classLoader)
Returns an
ApiSurface object representing the given package and all subpackages. |
ApiSurface |
pruningClass(java.lang.Class<?> clazz)
Returns an
ApiSurface like this one, but pruning references from the provided class. |
ApiSurface |
pruningClassName(java.lang.String className)
Returns an
ApiSurface like this one, but pruning references from the named class. |
ApiSurface |
pruningPattern(java.util.regex.Pattern pattern)
Returns an
ApiSurface like this one, but pruning transitive references from classes
whose full name (including package) begins with the provided prefix. |
ApiSurface |
pruningPattern(java.lang.String patternString)
|
ApiSurface |
pruningPrefix(java.lang.String prefix)
Returns an
ApiSurface like this one, but pruning transitive references from classes
whose full name (including package) begins with the provided prefix. |
public static org.hamcrest.Matcher<java.lang.Class<?>> classesInPackage(java.lang.String packageName)
Class
matcher for classes residing in a given package.public static org.hamcrest.Matcher<ApiSurface> containsOnlyClassesMatching(java.util.Set<org.hamcrest.Matcher<java.lang.Class<?>>> classMatchers)
ApiSurface
matcher, producing a positive match if the
queried api surface contains ONLY classes described by the provided matchers.@SafeVarargs public static org.hamcrest.Matcher<ApiSurface> containsOnlyClassesMatching(org.hamcrest.Matcher<java.lang.Class<?>>... classMatchers)
public static org.hamcrest.Matcher<ApiSurface> containsOnlyPackages(java.lang.String... packageNames)
public static org.hamcrest.Matcher<ApiSurface> containsOnlyPackages(java.util.Set<java.lang.String> packageNames)
ApiSurface
matcher, producing a positive match if the
queried api surface contains classes ONLY from specified package names.public static ApiSurface empty()
ApiSurface
.public static ApiSurface ofPackage(java.lang.String packageName, java.lang.ClassLoader classLoader) throws java.io.IOException
ApiSurface
object representing the given package and all subpackages.java.io.IOException
public static ApiSurface ofPackage(java.lang.Package aPackage, java.lang.ClassLoader classLoader) throws java.io.IOException
ApiSurface
object representing the given package and all subpackages.java.io.IOException
public static ApiSurface ofClass(java.lang.Class<?> clazz)
ApiSurface
object representing just the surface of the given class.public ApiSurface includingPackage(java.lang.String packageName, java.lang.ClassLoader classLoader) throws java.io.IOException
ApiSurface
like this one, but also including the named package and all of
its subpackages.java.io.IOException
public ApiSurface includingClass(java.lang.Class<?> clazz)
ApiSurface
like this one, but also including the given class.public ApiSurface pruningPrefix(java.lang.String prefix)
ApiSurface
like this one, but pruning transitive references from classes
whose full name (including package) begins with the provided prefix.public ApiSurface pruningClassName(java.lang.String className)
ApiSurface
like this one, but pruning references from the named class.public ApiSurface pruningClass(java.lang.Class<?> clazz)
ApiSurface
like this one, but pruning references from the provided class.public ApiSurface pruningPattern(java.util.regex.Pattern pattern)
ApiSurface
like this one, but pruning transitive references from classes
whose full name (including package) begins with the provided prefix.public ApiSurface pruningPattern(java.lang.String patternString)
public java.util.Set<java.lang.Class<?>> getRootClasses()
ApiSurface
.public java.util.Set<java.lang.Class<?>> getExposedClasses()
public java.util.List<java.lang.Class<?>> getAnyExposurePath(java.lang.Class<?> exposedClass)
If there are only cycles, with no path back to a root class, throws IllegalStateException.