2
* Copyright 2012 the original author or authors.
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
16
package org.gmetrics.result
18
import org.gmetrics.metric.Metric
19
import org.gmetrics.metric.MetricLevel
22
* A MetricResult for numbers (integers, BigDecimals, etc.), that returns the same, single value for
23
* total, average, minimum and maximum. An instance of this class is immutable.
27
class SingleNumberMetricResult implements MetricResult {
30
final MetricLevel metricLevel
32
final Integer lineNumber
36
* Construct a new instance
37
* @param metric - the Metric to which this result applies
38
* @param metricLevel - the metric level for this result
39
* @param number - the single value to use for total, average, minimum, and maximum
40
* @param lineNumber - the line number for the source element (AST) that triggered this metric result; may be null
42
SingleNumberMetricResult(Metric metric, MetricLevel metricLevel, number, Integer lineNumber=null) {
47
this.metricLevel = metricLevel
49
this.lineNumber = lineNumber
52
Object getAt(String name) {
53
return name in metric.functions ? number : null
57
"SingleNumberMetricResult[metric=${metric.name}, $number]"
b'\\ No newline at end of file'