Ejemplo n.º 1
0
 /**
  * Creates a transformed unit from the specified system unit.
  *
  * @parem symbol the symbol to use with this transformed unit.
  * @param parentUnit the system unit from which this unit is derived.
  * @param unitConverter the converter to the parent units.
  * @throws IllegalArgumentException if the specified parent unit is not an {@link
  *     AbstractUnit#isSystemUnit() system unit}
  */
 public TransformedUnit(String symbol, Unit<Q> parentUnit, UnitConverter unitConverter) {
   if (parentUnit instanceof AbstractUnit) {
     final AbstractUnit<Q> abParent = (AbstractUnit<Q>) parentUnit;
     if (!abParent.isSystemUnit()) {
       throw new IllegalArgumentException(
           "The parent unit: " + abParent + " is not a system unit");
     }
     this.parentUnit = abParent;
     this.converter = unitConverter;
     //        this.symbol = symbol; //TODO see
     // https://github.com/unitsofmeasurement/uom-se/issues/54
   } else {
     throw new IllegalArgumentException(
         "The parent unit: " + parentUnit + " is not an abstract unit.");
   }
 }
Ejemplo n.º 2
0
 /**
  * Creates a transformed unit from the specified system unit.
  *
  * @param parentUnit the system unit from which this unit is derived.
  * @param unitConverter the converter to the parent units.
  * @throws IllegalArgumentException if the specified parent unit is not an {@link
  *     AbstractUnit#isSystemUnit() system unit}
  */
 public TransformedUnit(AbstractUnit<Q> parentUnit, UnitConverter unitConverter) {
   if (!parentUnit.isSystemUnit())
     throw new IllegalArgumentException(
         "The parent unit: " + parentUnit + " is not a system unit");
   this.parentUnit = parentUnit;
   this.converter = unitConverter;
   //        this.symbol = parentUnit.getSymbol();
 }
Ejemplo n.º 3
0
 @Override
 public int hashCode() {
   return parentUnit.hashCode() + converter.hashCode();
 }
Ejemplo n.º 4
0
 @Override
 public Map<? extends Unit<?>, Integer> getProductUnits() {
   return parentUnit.getProductUnits();
 }
Ejemplo n.º 5
0
 @Override
 public AbstractUnit<Q> toSystemUnit() {
   return parentUnit.getSystemUnit();
 }
Ejemplo n.º 6
0
 @Override
 public UnitConverter getSystemConverter() {
   return parentUnit.getSystemConverter().concatenate(converter);
 }
Ejemplo n.º 7
0
 @Override
 public Dimension getDimension() {
   return parentUnit.getDimension();
 }