Пример #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.");
   }
 }
Пример #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();
 }
Пример #3
0
 @Override
 public int hashCode() {
   return parentUnit.hashCode() + converter.hashCode();
 }
Пример #4
0
 @Override
 public Map<? extends Unit<?>, Integer> getProductUnits() {
   return parentUnit.getProductUnits();
 }
Пример #5
0
 @Override
 public AbstractUnit<Q> toSystemUnit() {
   return parentUnit.getSystemUnit();
 }
Пример #6
0
 @Override
 public UnitConverter getSystemConverter() {
   return parentUnit.getSystemConverter().concatenate(converter);
 }
Пример #7
0
 @Override
 public Dimension getDimension() {
   return parentUnit.getDimension();
 }