1 2 12 package com.versant.core.metric; 13 14 18 public class DifferenceMetric extends DerivedMetric { 19 20 private Metric metricA; 21 private Metric metricB; 22 private final int defaultCalc; 23 24 public DifferenceMetric(String name, String displayName, String category, 25 String descr, Metric[] args) { 26 this(name, displayName, category, descr, args[0], args[1], 27 args[0].getDefaultCalc(), args[0].getDecimals()); 28 } 29 30 public DifferenceMetric(String name, String displayName, String category, String descr, 31 Metric metricA, Metric metricB, int defaultCalc, int decimals) { 32 super(name, displayName, category, descr, decimals); 33 this.metricA = metricA; 34 this.metricB = metricB; 35 this.defaultCalc = defaultCalc; 36 } 37 38 42 public int getArgCount() { 43 return 2; 44 } 45 46 54 public double get(MetricDataSource dataSet, int firstSampleNo, int lastSampleNo, 55 int calc, double seconds) { 56 return metricA.get(dataSet, firstSampleNo, lastSampleNo, calc, seconds) 57 - metricB.get(dataSet, firstSampleNo, lastSampleNo, calc, seconds); 58 } 59 60 63 public int getDefaultCalc() { 64 return defaultCalc; 65 } 66 67 } 68 69 | Popular Tags |