Class MetricsComponents<T>
java.lang.Object
com.tngtech.archunit.base.ForwardingCollection<MetricsComponent<T>>
com.tngtech.archunit.library.metrics.MetricsComponents<T>
- All Implemented Interfaces:
Iterable<MetricsComponent<T>>,Collection<MetricsComponent<T>>
@PublicAPI(usage=ACCESS)
public final class MetricsComponents<T>
extends ForwardingCollection<MetricsComponent<T>>
A collection of
MetricsComponent. Provides factory methods create components from
ArchUnit domain objects like JavaPackage or to componentize sets of elements.-
Method Summary
Modifier and TypeMethodDescriptionprotected Collection<MetricsComponent<T>>delegate()static <T> MetricsComponents<T>from(Collection<T> elements, Function<? super T, String> identifierFunction) Partitions the passed set of elements into components according to the specifiedidentifierFunction.static MetricsComponents<JavaClass>fromClasses(Collection<JavaClass> classes) Creates oneMetricsComponentfor each passedJavaClasscontaining only this class itself.static MetricsComponents<JavaClass>fromPackages(Collection<JavaPackage> packages) Creates oneMetricsComponentfor each passedJavaPackagecontaining all classes contained in the respective package or any subpackage.static <T> MetricsComponents<T>of(MetricsComponent<T>... components) static <T> MetricsComponents<T>of(Collection<MetricsComponent<T>> metricsComponents) CreatesMetricsComponentscontaining the supplied collection ofMetricsComponent.
Note that the identifiers of the passed components must all be unique.tryGetComponent(String identifier) Methods inherited from class com.tngtech.archunit.base.ForwardingCollection
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, spliterator, stream, toArray
-
Method Details
-
tryGetComponent
- Parameters:
identifier- The identifier of a component- Returns:
- The component with the specified identifier if present,
Optional.absent()otherwise.
-
delegate
- Specified by:
delegatein classForwardingCollection<MetricsComponent<T>>
-
of
@SafeVarargs @PublicAPI(usage=ACCESS) public static <T> MetricsComponents<T> of(MetricsComponent<T>... components) - See Also:
-
of
@PublicAPI(usage=ACCESS) public static <T> MetricsComponents<T> of(Collection<MetricsComponent<T>> metricsComponents) CreatesMetricsComponentscontaining the supplied collection ofMetricsComponent.
Note that the identifiers of the passed components must all be unique.- Type Parameters:
T- The type of the elements contained within each component- Parameters:
metricsComponents- The components the result will contain- Returns:
- The created
MetricsComponents - Throws:
IllegalArgumentException- if any two components have a duplicate identifier
-
from
@PublicAPI(usage=ACCESS) public static <T> MetricsComponents<T> from(Collection<T> elements, Function<? super T, String> identifierFunction) Partitions the passed set of elements into components according to the specifiedidentifierFunction. That is for each element ofelementsthe respective component identifier will be derived via the passedidentifierFunction. For each such identifier a component will be created and all elements with the same identifier will end up in the same component.- Type Parameters:
T- The type of the elements- Parameters:
elements- The elements to componentizeidentifierFunction- A function to create the respective identifier each element belongs to- Returns:
MetricsComponentscontaining one component for each unique identifier created this way
-
fromPackages
@PublicAPI(usage=ACCESS) public static MetricsComponents<JavaClass> fromPackages(Collection<JavaPackage> packages) Creates oneMetricsComponentfor each passedJavaPackagecontaining all classes contained in the respective package or any subpackage. Theidentifierfor each component will be the full package name of the respectiveJavaPackage.- Parameters:
packages- A collection ofpackagesto derive the components from- Returns:
MetricsComponentswhere components mirror the passed packages
-
fromClasses
@PublicAPI(usage=ACCESS) public static MetricsComponents<JavaClass> fromClasses(Collection<JavaClass> classes) Creates oneMetricsComponentfor each passedJavaClasscontaining only this class itself. Theidentifierfor each component will be the fully qualified class name of the containedJavaClass.- Parameters:
classes- Theclassesto created components from- Returns:
MetricsComponentswhere components mirror the passed classes one to one
-