Class PackageUtils
java.lang.Object
org.junit.platform.commons.util.PackageUtils
Collection of utilities for working with packages.
DISCLAIMER
These utilities are intended solely for usage within the JUnit framework itself. Any usage by external parties is not supported. Use at your own risk!
- Since:
- 1.0
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiongetAttribute(Class<?> type, String name) Get the value of the specified attribute name, specified as a string, or an emptyOptionalif the attribute was not found.getAttribute(Class<?> type, Function<Package, String> function) Get the package attribute for the suppliedtypeusing the suppliedfunction.getModuleOrImplementationVersion(Class<?> type) Get the module or implementation version for the suppliedtype.
-
Field Details
-
DEFAULT_PACKAGE_NAME
- See Also:
-
-
Method Details
-
getAttribute
Get the package attribute for the suppliedtypeusing the suppliedfunction.This method only returns a non-empty
Optionalvalue holder if the class loader for the supplied type created aPackageobject and the supplied function does not returnnullwhen applied.- Parameters:
type- the type to get the package attribute forfunction- a function that computes the package attribute value (e.g.,Package::getImplementationTitle); nevernull- Returns:
- an
Optionalcontaining the attribute value; nevernullbut potentially empty - Throws:
PreconditionViolationException- if the supplied type or function isnull- See Also:
-
getAttribute
Get the value of the specified attribute name, specified as a string, or an emptyOptionalif the attribute was not found. The attribute name is case-insensitive.This method also returns an empty
Optionalvalue holder if any exception is caught while loading the manifest file via the JAR file of the specified type.- Parameters:
type- the type to get the attribute forname- the attribute name as a string- Returns:
- an
Optionalcontaining the attribute value; nevernullbut potentially empty - Throws:
PreconditionViolationException- if the supplied type isnullor the specified name is blank- See Also:
-
getModuleOrImplementationVersion
@API(status=INTERNAL, since="1.11") public static Optional<String> getModuleOrImplementationVersion(Class<?> type) Get the module or implementation version for the suppliedtype.The former is only available if the type is part of a versioned module on the module path; the latter only if the type is part of a JAR file with a manifest that contains an
Implementation-Versionattribute.- Since:
- 1.11
-