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 Deprecated Methods Modifier and Type Method Description static <O extends Node>
doublecomputeAggregate(MetricKey<? super O> key, Iterable<? extends O> ops, MetricOptions options, ResultOption resultOption)Computes an aggregate result for a metric, identified with aResultOption.static <O extends Node>
doublecomputeAggregate(MetricKey<? super O> key, Iterable<? extends O> ops, ResultOption resultOption)static <N extends Node>
doublecomputeMetric(MetricKey<? super N> key, N node)Computes a metric identified by its code on a node, with the default options.static <N extends Node>
doublecomputeMetric(MetricKey<? super N> key, N node, MetricOptions options)Computes a metric identified by its code on a node, possibly selecting a variant with theoptionsparameter.static <N extends Node>
doublecomputeMetric(MetricKey<? super N> key, N node, MetricOptions options, boolean forceRecompute)Computes a metric identified by its code on a node, possibly selecting a variant with theoptionsparameter.static <N extends Node>
doublecomputeMetricOrNaN(MetricKey<? super N> key, N node, MetricOptions options)Deprecated.This is provided for compatibility with pre 6.21.0 behavior.static <N extends Node>
booleansupportsAll(N node, MetricKey<N>... metrics)
-
-
-
Method Detail
-
computeAggregate
public static <O extends Node> double computeAggregate(MetricKey<? super O> key, Iterable<? extends O> ops, ResultOption resultOption)
-
computeAggregate
public static <O extends Node> double computeAggregate(MetricKey<? super O> key, Iterable<? extends O> ops, MetricOptions options, ResultOption resultOption)
Computes an aggregate result for a metric, identified with aResultOption.- Parameters:
key- The metric to computeops- List of nodes for which to aggregate the metricoptions- The options of the metricresultOption- The type of aggregation to perform- Returns:
- The result of the computation, or
Double.NaNif it couldn't be performed
-
computeMetric
public static <N extends Node> double computeMetric(MetricKey<? super N> 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.NaNif the value couldn't be computed
-
computeMetricOrNaN
@Deprecated public static <N extends Node> double computeMetricOrNaN(MetricKey<? super N> key, N node, MetricOptions options)
Deprecated.This is provided for compatibility with pre 6.21.0 behavior. Users of a metric should always check beforehand if the metric supports the argument.Computes a metric identified by its code on a node, possibly selecting a variant with theoptionsparameter.- 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, or
Double.NaNif the value couldn't be computed
-
computeMetric
public static <N extends Node> double computeMetric(MetricKey<? super N> key, N node, MetricOptions options)
Computes a metric identified by its code on a node, possibly selecting a variant with theoptionsparameter.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> double computeMetric(MetricKey<? super N> key, N node, MetricOptions options, boolean forceRecompute)
Computes a metric identified by its code on a node, possibly selecting a variant with theoptionsparameter.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
-
-