/** * Multiplies this unit by another unit. This operation is invalid. * * @param that The other unit. * @return The product of multiplying this unit by the other unit. * @throws MultiplyException Illegal operation. Always thrown. */ @Override protected Unit myMultiplyBy(final Unit that) throws MultiplyException { throw new MultiplyException(this); }
/** * Multiplies this unit by another unit. This operation is invalid. * * @param that The other unit. * @return The product of multiplying this unit by the other unit. * @throws MultiplyException Illegal operation. Always thrown. */ @Override protected Unit myMultiplyBy(final Unit that) throws MultiplyException { throw new MultiplyException(this); }
static Unit getInstance(final double scale, final Unit unit) throws MultiplyException { if (scale == 0) { throw new MultiplyException(scale, unit); } return scale == 1 ? unit : new ScaledUnit(scale, unit); }
static Unit getInstance(final double scale, final Unit unit) throws MultiplyException { if (scale == 0) { throw new MultiplyException(scale, unit); } return scale == 1 ? unit : new ScaledUnit(scale, unit); }
@Override public Unit multiplyBy(final double scale) throws MultiplyException { if (scale == 0) { throw new MultiplyException(scale, this); } return getInstance(_unit.multiplyBy(scale), _offset / scale); }
@Override public Unit multiplyBy(final double scale) throws MultiplyException { if (scale == 0) { throw new MultiplyException(scale, this); } return getInstance(_unit.multiplyBy(scale), _offset / scale); }
/** * Multiply this unit by another unit. * * @param that * The unit to multiply this unit by. Must be dimensionless. * @return The product of this unit and <code>that</code>. * @throws MultiplyException * Can't multiply these units together. */ @Override protected Unit myMultiplyBy(final Unit that) throws MultiplyException { if (!that.isDimensionless()) { throw new MultiplyException(that); } return that instanceof ScaledUnit ? new ScaledUnit(((ScaledUnit) that).getScale(), this) : this; }
/** * Multiply this unit by another unit. * * @param that * The unit to multiply this unit by. Must be dimensionless. * @return The product of this unit and <code>that</code>. * @throws MultiplyException * Can't multiply these units together. */ @Override protected Unit myMultiplyBy(final Unit that) throws MultiplyException { if (!that.isDimensionless()) { throw new MultiplyException(that); } return that instanceof ScaledUnit ? new ScaledUnit(((ScaledUnit) that).getScale(), this) : this; }