1 9 package org.jscience.physics.units; 10 11 19 public final class MultiplyConverter extends Converter { 20 21 24 private final double _factor; 25 26 31 public MultiplyConverter(double factor) { 32 _factor = factor; 33 } 34 35 public Converter inverse() { 37 return new MultiplyConverter(1.0 / _factor); 38 } 39 40 public double convert(double amount) { 42 return _factor * amount; 43 } 44 45 public double derivative(double x) { 47 return _factor; 48 } 49 50 public boolean isLinear() { 52 return true; 53 } 54 55 public Converter concatenate(Converter converter) { 57 if (converter instanceof MultiplyConverter) { 58 double factor = _factor * ((MultiplyConverter)converter)._factor; 60 return new MultiplyConverter(factor); 61 } else { 62 return super.concatenate(converter); 63 } 64 } 65 66 private static final long serialVersionUID = 1L; 67 } | Popular Tags |