1 9 package org.jscience.physics.units; 10 11 import org.jscience.physics.quantities.Quantity; 12 13 26 public class CompoundUnit<Q extends Quantity> extends DerivedUnit<Q> { 27 28 31 private final Unit<Q> _mainUnit; 32 33 36 private final Unit<Q> _subUnit; 37 38 44 protected CompoundUnit(Unit<Q> mainUnit, Unit<Q> subUnit) { 45 _mainUnit = mainUnit; 46 _subUnit = subUnit; 47 } 48 49 54 public Unit<Q> getMainUnit() { 55 return _mainUnit; 56 } 57 58 63 public Unit<Q> getSubUnit() { 64 return _subUnit; 65 } 66 67 protected boolean equalsImpl(Object that) { 69 return (that instanceof CompoundUnit) 70 && (((CompoundUnit) that)._mainUnit == _mainUnit) 71 && ((CompoundUnit) that)._subUnit.equals(_subUnit); 72 } 73 74 protected int hashCodeImpl() { 76 return _mainUnit.hashCode() ^ _subUnit.hashCode(); 77 } 78 79 protected Unit<? super Q> getParentUnitImpl() { 81 return _mainUnit.getParentUnit(); 82 } 83 84 protected Converter toParentUnitImpl() { 86 return _mainUnit.toParentUnit(); 87 } 88 89 private static final long serialVersionUID = 1L; 90 } | Popular Tags |