Package net.sourceforge.pmd.lang.metrics
Class AbstractMetricsFacade<T extends QualifiableNode,O extends QualifiableNode>
- java.lang.Object
-
- net.sourceforge.pmd.lang.metrics.AbstractMetricsFacade<T,O>
-
- Type Parameters:
T- Type of type declaration nodes of the languageO- Type of operation declaration nodes of the language
public abstract class AbstractMetricsFacade<T extends QualifiableNode,O extends QualifiableNode> extends Object
Base class for a façade that can compute metrics for types, operations and compute aggregate results with a result option.- Since:
- 6.0.0
- Author:
- Clément Fournier
-
-
Constructor Summary
Constructors Constructor Description AbstractMetricsFacade()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description doublecomputeForOperation(MetricKey<O> key, O node, MetricOptions options)Computes a metric identified by its key on a operation AST node.doublecomputeForType(MetricKey<T> key, T node, MetricOptions options)Computes a metric identified by its code on a class AST node, possibly selecting a variant with theMetricOptionsparameter.doublecomputeWithResultOption(MetricKey<O> key, T node, MetricOptions options, ResultOption resultOption)Compute the sum, average, or highest value of the operation metric on all operations of the class node.protected abstract MetricsComputer<T,O>getLanguageSpecificComputer()Gets the language specific metrics computer.protected abstract ProjectMemoizer<T,O>getLanguageSpecificProjectMemoizer()Gets the language-specific project memoizer.
-
-
-
Method Detail
-
getLanguageSpecificComputer
protected abstract MetricsComputer<T,O> getLanguageSpecificComputer()
Gets the language specific metrics computer.- Returns:
- The metrics computer
-
getLanguageSpecificProjectMemoizer
protected abstract ProjectMemoizer<T,O> getLanguageSpecificProjectMemoizer()
Gets the language-specific project memoizer.- Returns:
- The project memoizer
-
computeForType
public double computeForType(MetricKey<T> key, T node, MetricOptions options)
Computes a metric identified by its code on a class AST node, possibly selecting a variant with theMetricOptionsparameter.- 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
-
computeForOperation
public double computeForOperation(MetricKey<O> key, O node, MetricOptions options)
Computes a metric identified by its key on a operation AST 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, or
Double.NaNif the value couldn't be computed
-
computeWithResultOption
public double computeWithResultOption(MetricKey<O> key, T node, MetricOptions options, ResultOption resultOption)
Compute the sum, average, or highest value of the operation metric on all operations of the class node. The type of operation is specified by theResultOptionparameter.- Parameters:
key- The key identifying the metric to be computednode- The node on which to compute the metricresultOption- The result option to useoptions- The options of the metric- Returns:
- The value of the metric, or
Double.NaNif the value couldn't be computed orresultOptionisnull
-
-