Package net.sourceforge.pmd.lang.metrics
Class MetricsUtil
- java.lang.Object
-
- net.sourceforge.pmd.lang.metrics.MetricsUtil
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <N extends Node,R extends Number>
RcomputeMetric(Metric<? super N,R> key, N node)
Computes a metric identified by its code on a node, with the default options.static <N extends Node,R extends Number>
RcomputeMetric(Metric<? super N,R> key, N node, MetricOptions options)
Computes a metric identified by its code on a node, possibly selecting a variant with theoptions
parameter.static <N extends Node,R extends Number>
RcomputeMetric(Metric<? super N,R> key, N node, MetricOptions options, boolean forceRecompute)
Computes a metric identified by its code on a node, possibly selecting a variant with theoptions
parameter.static <O extends Node>
DoubleSummaryStatisticscomputeStatistics(Metric<? super O,?> key, Iterable<? extends O> ops)
Computes statistics for the results of a metric over a sequence of nodes.static <O extends Node>
DoubleSummaryStatisticscomputeStatistics(Metric<? super O,?> key, Iterable<? extends O> ops, MetricOptions options)
Computes statistics for the results of a metric over a sequence of nodes.static boolean
supportsAll(Node node, Metric<?,?>... metrics)
-
-
-
Method Detail
-
computeStatistics
public static <O extends Node> DoubleSummaryStatistics computeStatistics(Metric<? super O,?> key, Iterable<? extends O> ops)
Computes statistics for the results of a metric over a sequence of nodes.- Parameters:
key
- The metric to computeops
- List of nodes for which to compute the metric- Returns:
- Statistics for the value of the metric over all the nodes
-
computeStatistics
public static <O extends Node> DoubleSummaryStatistics computeStatistics(Metric<? super O,?> key, Iterable<? extends O> ops, MetricOptions options)
Computes statistics for the results of a metric over a sequence of nodes.- Parameters:
key
- The metric to computeops
- List of nodes for which to compute the metricoptions
- The options of the metric- Returns:
- Statistics for the value of the metric over all the nodes
-
computeMetric
public static <N extends Node,R extends Number> R computeMetric(Metric<? super N,R> key, N node)
Computes a metric identified by its code on a node, with the default options.- Parameters:
key
- The key identifying the metric to be computednode
- The node on which to compute the metric- Returns:
- The value of the metric, or
Double.NaN
if the value couldn't be computed - Throws:
IllegalArgumentException
- If the metric does not support the given node
-
computeMetric
public static <N extends Node,R extends Number> R computeMetric(Metric<? super N,R> key, N node, MetricOptions options)
Computes a metric identified by its code on a node, possibly selecting a variant with theoptions
parameter.Note that contrary to the previous behaviour, this method throws an exception if the metric does not support the node.
- Parameters:
key
- The key identifying the metric to be computednode
- The node on which to compute the metricoptions
- The options of the metric- Returns:
- The value of the metric
- Throws:
IllegalArgumentException
- If the metric does not support the given node
-
computeMetric
public static <N extends Node,R extends Number> R computeMetric(Metric<? super N,R> key, N node, MetricOptions options, boolean forceRecompute)
Computes a metric identified by its code on a node, possibly selecting a variant with theoptions
parameter.Note that contrary to the previous behaviour, this method throws an exception if the metric does not support the node.
- Parameters:
key
- The key identifying the metric to be computednode
- The node on which to compute the metricoptions
- The options of the metricforceRecompute
- Force recomputation of the result- Returns:
- The value of the metric
- Throws:
IllegalArgumentException
- If the metric does not support the given node
-
-