@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. * @return The product of this unit and <code>that</code>. The offset of * this unit will be ignored; thus, for example * "celsius.myMultiplyBy(day)" is equivalent to * "kelvin.myMultiplyBy(day)". * @throws MultiplyException * Can't multiply these units together. */ @Override protected Unit myMultiplyBy(final Unit that) throws MultiplyException { return that instanceof OffsetUnit ? getUnit().multiplyBy(((OffsetUnit) that).getUnit()) : getUnit().multiplyBy(that); }
@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. * @return The product of this unit and <code>that</code>. The offset of * this unit will be ignored; thus, for example * "celsius.myMultiplyBy(day)" is equivalent to * "kelvin.myMultiplyBy(day)". * @throws MultiplyException * Can't multiply these units together. */ @Override protected Unit myMultiplyBy(final Unit that) throws MultiplyException { return that instanceof OffsetUnit ? getUnit().multiplyBy(((OffsetUnit) that).getUnit()) : getUnit().multiplyBy(that); }
/** * Multiplies this unit by another unit. * * @param that * The other unit. * @return The product of this unit and the other unit. * @throws MultiplyException * Can't multiply these units together. */ @Override protected Unit myMultiplyBy(final Unit that) throws MultiplyException { return that instanceof ScaledUnit ? new ScaledUnit(getScale() * ((ScaledUnit) that).getScale(), getUnit().multiplyBy(((ScaledUnit) that).getUnit())) : new ScaledUnit(getScale(), getUnit().multiplyBy(that)); }
/** * Multiplies this unit by another unit. * * @param that * The other unit. * @return The product of this unit and the other unit. * @throws MultiplyException * Can't multiply these units together. */ @Override protected Unit myMultiplyBy(final Unit that) throws MultiplyException { return that instanceof ScaledUnit ? new ScaledUnit(getScale() * ((ScaledUnit) that).getScale(), getUnit().multiplyBy(((ScaledUnit) that).getUnit())) : new ScaledUnit(getScale(), getUnit().multiplyBy(that)); }
final Unit s = parser.parse("s"); final Unit epoch = parser.parse("s @ 1970-01-01 00:00:00 UTC"); myAssert(parser, "m m", m.multiplyBy(m)); myAssert(parser, "m.m", m.multiplyBy(m)); myAssert(parser, "(m)(m)", m.multiplyBy(m)); myAssert(parser, "m/s/s", m.divideBy(s).divideBy(s)); myAssert(parser, "m2", m.raiseTo(2)); myAssert(parser, "m2.s", m.raiseTo(2).multiplyBy(s)); myAssert(parser, "m2/s", m.raiseTo(2).divideBy(s)); myAssert(parser, "m^2/s", m.raiseTo(2).divideBy(s)); myAssert(parser, "m s @ 5", m.multiplyBy(s).shiftTo(5.0)); myAssert(parser, "m2 s @ 5", m.raiseTo(2).multiplyBy(s).shiftTo(5)); myAssert(parser, "m2 s-1 @ 5", m.raiseTo(2).multiplyBy(s.raiseTo(-1)) .shiftTo(5)); myAssert(parser, "m s from 5", m.multiplyBy(s).shiftTo(5)); myAssert(parser, "s@19700101", epoch); myAssert(parser, "s@19700101T000000", epoch); myAssert(parser, "0.1 lg(re 1 mm)", m.multiplyBy(1e-3).log(10) .multiplyBy(0.1)); myAssert(parser, "m", m); myAssert(parser, "2 m s", m.multiplyBy(s).multiplyBy(2)); myAssert(parser, "3.14 m.s", m.multiplyBy(s).multiplyBy(3.14)); myAssert(parser, "1e9 (m)", m.multiplyBy(1e9)); myAssert(parser, "(m s)2", m.multiplyBy(s).raiseTo(2)); myAssert(parser, "m2.s-1", m.raiseTo(2).divideBy(s)); myAssert(parser, "m2 s^-1", m.raiseTo(2).divideBy(s)); myAssert(parser, "m2/s-1", m.raiseTo(2).divideBy(s.raiseTo(-1)));
final Unit s = parser.parse("s"); final Unit epoch = parser.parse("s @ 1970-01-01 00:00:00 UTC"); myAssert(parser, "m m", m.multiplyBy(m)); myAssert(parser, "m.m", m.multiplyBy(m)); myAssert(parser, "(m)(m)", m.multiplyBy(m)); myAssert(parser, "m/s/s", m.divideBy(s).divideBy(s)); myAssert(parser, "m2", m.raiseTo(2)); myAssert(parser, "m2.s", m.raiseTo(2).multiplyBy(s)); myAssert(parser, "m2/s", m.raiseTo(2).divideBy(s)); myAssert(parser, "m^2/s", m.raiseTo(2).divideBy(s)); myAssert(parser, "m s @ 5", m.multiplyBy(s).shiftTo(5.0)); myAssert(parser, "m2 s @ 5", m.raiseTo(2).multiplyBy(s).shiftTo(5)); myAssert(parser, "m2 s-1 @ 5", m.raiseTo(2).multiplyBy(s.raiseTo(-1)) .shiftTo(5)); myAssert(parser, "m s from 5", m.multiplyBy(s).shiftTo(5)); myAssert(parser, "s@19700101", epoch); myAssert(parser, "s@19700101T000000", epoch); myAssert(parser, "0.1 lg(re 1 mm)", m.multiplyBy(1e-3).log(10) .multiplyBy(0.1)); myAssert(parser, "m", m); myAssert(parser, "2 m s", m.multiplyBy(s).multiplyBy(2)); myAssert(parser, "3.14 m.s", m.multiplyBy(s).multiplyBy(3.14)); myAssert(parser, "1e9 (m)", m.multiplyBy(1e9)); myAssert(parser, "(m s)2", m.multiplyBy(s).raiseTo(2)); myAssert(parser, "m2.s-1", m.raiseTo(2).divideBy(s)); myAssert(parser, "m2 s^-1", m.raiseTo(2).divideBy(s)); myAssert(parser, "m2/s-1", m.raiseTo(2).divideBy(s.raiseTo(-1)));
/** * Multiplies this derived unit by another. * * @param that * The other unit. * @return The product of the two units. * @throws MultiplyException * Can't multiply these units. */ @Override protected Unit myMultiplyBy(final Unit that) throws MultiplyException { Unit result; if (dimension.getRank() == 0) { result = that; } else { if (!(that instanceof DerivedUnit)) { result = that.multiplyBy(this); } else { final UnitDimension thatDimension = ((DerivedUnit) that) .getDimension(); result = thatDimension.getRank() == 0 ? this : new DerivedUnitImpl(dimension .multiplyBy(thatDimension)); } } return result; }
/** * Multiplies this derived unit by another. * * @param that * The other unit. * @return The product of the two units. * @throws MultiplyException * Can't multiply these units. */ @Override protected Unit myMultiplyBy(final Unit that) throws MultiplyException { Unit result; if (dimension.getRank() == 0) { result = that; } else { if (!(that instanceof DerivedUnit)) { result = that.multiplyBy(this); } else { final UnitDimension thatDimension = ((DerivedUnit) that) .getDimension(); result = thatDimension.getRank() == 0 ? this : new DerivedUnitImpl(dimension .multiplyBy(thatDimension)); } } return result; }
string = string.substring(prefix.length()); unit = unit.multiplyBy(scale);
string = string.substring(prefix.length()); unit = unit.multiplyBy(scale);
unit = unit.multiplyBy(unit2); } else { jj_consume_token(-1);
unit = unit.multiplyBy(unit2); } else { jj_consume_token(-1);