Class MetricsComponent<T>
java.lang.Object
com.tngtech.archunit.base.ForwardingCollection<T>
com.tngtech.archunit.library.metrics.MetricsComponent<T>
- Type Parameters:
T
- The type of the elements this component contains, e.g.JavaClass
- All Implemented Interfaces:
java.lang.Iterable<T>
,java.util.Collection<T>
@PublicAPI(usage=ACCESS) public final class MetricsComponent<T> extends ForwardingCollection<T>
Represents a component of the software system. The term "component" does not impose any wider
restriction than that it contains a set of elements which all share a common string identifier.
Thus by definition two components are equal, if and only if they have the same identifier.
The elements that a component contains are principally completely free. It could be
This abstraction is powerful enough to be applied to a wide variety of scenarios. For example
Thus by definition two components are equal, if and only if they have the same identifier.
The elements that a component contains are principally completely free. It could be
JavaClasses
or JavaPackages
, but also any other type
of objects where software metrics can be calculated on. Specific metrics might then impose
type restrictions on the element, e.g. if metrics can only be calculated for elements that
specify their dependencies on other elements.
This abstraction is powerful enough to be applied to a wide variety of scenarios. For example
- Partitioning classes by their packages and using the package name as identifier would create one component per package
- Using the (unique) name of a build module and grouping all classes in that module
- Partitioning classes by their fully qualified class name would create one component per class
- Partitioning methods by their declaring class name would create components each containing exactly the methods of one specific class
-
Method Summary
Modifier and Type Method Description protected java.util.Collection<T>
delegate()
java.util.Set<T>
getElements()
java.lang.String
getIdentifier()
static <T> MetricsComponent<T>
of(java.lang.String identifier, java.util.Collection<T> elements)
static <T> MetricsComponent<T>
of(java.lang.String identifier, T... elements)
java.lang.String
toString()
Methods inherited from class com.tngtech.archunit.base.ForwardingCollection
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, spliterator, stream, toArray
Methods inherited from interface java.lang.Iterable
forEach
-
Method Details
-
getIdentifier
- Returns:
- The (unique) identifier of this component
- See Also:
MetricsComponent
-
getElements
- Returns:
- The elements contained in this component
- See Also:
MetricsComponent
-
delegate
- Specified by:
delegate
in classForwardingCollection<T>
-
toString
public java.lang.String toString()- Overrides:
toString
in classForwardingCollection<T>
-
of
@SafeVarargs @PublicAPI(usage=ACCESS) public static <T> MetricsComponent<T> of(java.lang.String identifier, T... elements)- See Also:
of(String, Collection)
-
of
@PublicAPI(usage=ACCESS) public static <T> MetricsComponent<T> of(java.lang.String identifier, java.util.Collection<T> elements)- Type Parameters:
T
- The type of the elements inside of this component- Parameters:
identifier
- The (unique) identifier of this componentelements
- The elements contained inside of this component- Returns:
- A new
MetricsComponent
-