1 9 package org.jscience.physics.units; 10 import org.jscience.physics.quantities.Quantity; 11 12 import javolution.realtime.LocalReference; 13 14 30 public class BaseUnit<Q extends Quantity> extends Unit<Q> { 31 32 35 final LocalReference<Dimension> _dimension; 36 37 40 final LocalReference<Converter> _transform; 41 42 51 public BaseUnit(String symbol, Dimension dimension, Converter transform) { 52 _symbol = symbol; 53 _dimension = new LocalReference<Dimension>(dimension); 54 _transform = new LocalReference<Converter>(transform); 55 getInstance(this); } 57 58 63 public final String getSymbol() { 64 return _symbol; 65 } 66 67 84 public void setDimension(Dimension dimension, Converter transform) { 85 _dimension.set(dimension); 86 _transform.set(transform); 87 } 88 89 protected boolean equalsImpl(Object that) { 91 return (that instanceof BaseUnit) && 92 ((BaseUnit) that)._symbol.equals(_symbol); 93 } 94 95 protected int hashCodeImpl() { 97 return _symbol.hashCode(); 98 } 99 100 protected Unit<Q> getParentUnitImpl() { 102 return this; 103 } 104 105 protected Converter toParentUnitImpl() { 107 return Converter.IDENTITY; 108 } 109 110 private static final long serialVersionUID = 1L; 111 } | Popular Tags |