/** * Returns a new {@code Unit} that is the addition of this {@code Unit} and * the {@code Unit} specified. * * @param that the {@code Unit} that should be added to this {@code Unit} * * @return a new {@code Unit} that is the addition of this {@code Unit} and * the {@code Unit} specified. * * @throws RuntimeException if the two {@code Unit} s are not the same */ Unit add(Unit that) { if (!this.equals(that)) { throw new ArithmeticException("Cannot add " + this + " to " + that); } return this; }
/** * Returns a new {@code Unit} that is the subtraction between this * {@code Unit} and the {@code Unit} specified. * * @param that the {@code Unit} that will be subtracted from this * {@code Unit} * @return a new {@code Unit} that is the subtraction between this * {@code Unit} and the {@code Unit} specified. * * @throws RuntimeException if the {@code Unit} specified is not the same as * this {@code Unit} */ Unit sub(Unit that) { if (!this.equals(that)) { throw new ArithmeticException("Cannot subtract " + that + " from " + this); } return this; }
/** * Returns whether the specified object is equal to this object. Two * {@code Measurement} objects are equal if they have same value, error and * {@code Unit}. * * <p> * Note: This class has a natural ordering that is inconsistent with equals. * See {@link #compareTo(Object)}. * * @param obj The object to compare with this object. * @return {@code true} if this object is equal to the specified object; * {@code false} otherwise. */ public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof Measurement)) { return false; } Measurement that = (Measurement) obj; return (Double.compare(value, that.value) == 0) && (Double.compare(error, that.error) == 0) && unit.equals(that.unit); } }
if (!unit.equals(that.unit)) { throw new ArithmeticException("Cannot compare " + this + " and " + that);
if (!Unit.rad.equals(lat.getUnit())) { throw new IllegalArgumentException("Invalid Latitude"); if (!Unit.rad.equals(lon.getUnit())) { throw new IllegalArgumentException("Invalid Longitude"); if (!Unit.m.equals(alt.getUnit())) { throw new IllegalArgumentException("Invalid Altitude"); if (!Unit.m_s.equals(speed.getUnit())) { throw new IllegalArgumentException("Invalid Speed"); if (!Unit.rad.equals(track.getUnit())) { throw new IllegalArgumentException("Invalid Track");
/** * Returns a new <code>Unit</code> that is the addition of this <code>Unit</code> * and the <code>Unit</code> specified. * * @param that the <code>Unit</code> that should be added to this * <code>Unit</code> * * @return a new <code>Unit</code> that is the addition of this <code>Unit</code> * and the <code>Unit</code> specified. * * @throws RuntimeException if the two <code>Unit</code> s are not the same */ Unit add(Unit that) { if (!this.equals(that)) { throw new ArithmeticException("Cannot add " + this + " to " + that); } return this; }
/** * Returns a new <code>Unit</code> that is the subtraction between this * <code>Unit</code> and the <code>Unit</code> specified. * * @param that the <code>Unit</code> that will be subtracted from this * <code>Unit</code> * @return a new <code>Unit</code> that is the subtraction between this * <code>Unit</code> and the <code>Unit</code> specified. * * @throws RuntimeException if the <code>Unit</code> specified is not the same * as this <code>Unit</code> */ Unit sub(Unit that) { if (!this.equals(that)) { throw new ArithmeticException("Cannot subtract " + that + " from " + this); } return this; }
/** * Returns whether the specified object is equal to this object. Two * <code>Measurement</code> objects are equal if they have same value, error * and <code>Unit</code>. * * <p> * Note: This class has a natural ordering that is inconsistent with equals. * See {@link #compareTo}. * * @param obj The object to compare with this object. * @return <code>true</code> if this object is equal to the specified object; * <code>false</code> otherwise. */ public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof Measurement)) { return false; } Measurement that = (Measurement) obj; return (Double.compare(value, that.value) == 0) && (Double.compare(error, that.error) == 0) && unit.equals(that.unit); } }
if (!unit.equals(that.unit)) { throw new ArithmeticException("Cannot compare " + this + " and " + that);
Measurement speed, Measurement track) { if (lat != null) { if (!Unit.rad.equals(lat.getUnit())) { throw new IllegalArgumentException("Invalid Latitude"); if (!Unit.rad.equals(lon.getUnit())) { throw new IllegalArgumentException("Invalid Longitude"); if (!Unit.m.equals(alt.getUnit())) { throw new IllegalArgumentException("Invalid Altitude"); if (!Unit.m_s.equals(speed.getUnit())) { throw new IllegalArgumentException("Invalid Speed"); if (!Unit.rad.equals(track.getUnit())) { throw new IllegalArgumentException("Invalid Track");
/** * Returns a new {@code Unit} that is the addition of this {@code Unit} and * the {@code Unit} specified. * * @param that the {@code Unit} that should be added to this {@code Unit} * * @return a new {@code Unit} that is the addition of this {@code Unit} and * the {@code Unit} specified. * * @throws RuntimeException if the two {@code Unit} s are not the same */ Unit add(Unit that) { if (!this.equals(that)) { throw new ArithmeticException("Cannot add " + this + " to " + that); } return this; }
/** * Returns a new {@code Unit} that is the subtraction between this * {@code Unit} and the {@code Unit} specified. * * @param that the {@code Unit} that will be subtracted from this * {@code Unit} * @return a new {@code Unit} that is the subtraction between this * {@code Unit} and the {@code Unit} specified. * * @throws RuntimeException if the {@code Unit} specified is not the same as * this {@code Unit} */ Unit sub(Unit that) { if (!this.equals(that)) { throw new ArithmeticException("Cannot subtract " + that + " from " + this); } return this; }
/** * Returns a new {@code Unit} that is the addition of this {@code Unit} and * the {@code Unit} specified. * * @param that the {@code Unit} that should be added to this {@code Unit} * * @return a new {@code Unit} that is the addition of this {@code Unit} and * the {@code Unit} specified. * * @throws RuntimeException if the two {@code Unit} s are not the same */ Unit add(Unit that) { if (!this.equals(that)) { throw new ArithmeticException("Cannot add " + this + " to " + that); } return this; }
/** * Returns a new {@code Unit} that is the addition of this {@code Unit} and * the {@code Unit} specified. * * @param that the {@code Unit} that should be added to this {@code Unit} * * @return a new {@code Unit} that is the addition of this {@code Unit} and * the {@code Unit} specified. * * @throws RuntimeException if the two {@code Unit} s are not the same */ Unit add(Unit that) { if (!this.equals(that)) { throw new ArithmeticException("Cannot add " + this + " to " + that); } return this; }
/** * Returns a new {@code Unit} that is the subtraction between this * {@code Unit} and the {@code Unit} specified. * * @param that the {@code Unit} that will be subtracted from this * {@code Unit} * @return a new {@code Unit} that is the subtraction between this * {@code Unit} and the {@code Unit} specified. * * @throws RuntimeException if the {@code Unit} specified is not the same as * this {@code Unit} */ Unit sub(Unit that) { if (!this.equals(that)) { throw new ArithmeticException("Cannot subtract " + that + " from " + this); } return this; }
/** * Returns a new {@code Unit} that is the subtraction between this * {@code Unit} and the {@code Unit} specified. * * @param that the {@code Unit} that will be subtracted from this * {@code Unit} * @return a new {@code Unit} that is the subtraction between this * {@code Unit} and the {@code Unit} specified. * * @throws RuntimeException if the {@code Unit} specified is not the same as * this {@code Unit} */ Unit sub(Unit that) { if (!this.equals(that)) { throw new ArithmeticException("Cannot subtract " + that + " from " + this); } return this; }
/** * Returns a new {@code Unit} that is the addition of this {@code Unit} * and the {@code Unit} specified. * * @param that the {@code Unit} that should be added to this * {@code Unit} * * @return a new {@code Unit} that is the addition of this {@code Unit} * and the {@code Unit} specified. * * @throws RuntimeException if the two {@code Unit} s are not the same */ Unit add(Unit that) { if (!this.equals(that)) { throw new ArithmeticException("Cannot add " + this + " to " + that); } return this; }
/** * Returns a new {@code Unit} that is the subtraction between this * {@code Unit} and the {@code Unit} specified. * * @param that the {@code Unit} that will be subtracted from this * {@code Unit} * @return a new {@code Unit} that is the subtraction between this * {@code Unit} and the {@code Unit} specified. * * @throws RuntimeException if the {@code Unit} specified is not the same as * this {@code Unit} */ Unit sub(Unit that) { if (!this.equals(that)) { throw new ArithmeticException("Cannot subtract " + that + " from " + this); } return this; }
/** * Returns a new {@code Unit} that is the addition of this {@code Unit} and * the {@code Unit} specified. * * @param that the {@code Unit} that should be added to this {@code Unit} * * @return a new {@code Unit} that is the addition of this {@code Unit} and * the {@code Unit} specified. * * @throws RuntimeException if the two {@code Unit} s are not the same */ Unit add(Unit that) { if (!this.equals(that)) { throw new ArithmeticException("Cannot add " + this + " to " + that); } return this; }
/** * Returns a new {@code Unit} that is the addition of this {@code Unit} and * the {@code Unit} specified. * * @param that the {@code Unit} that should be added to this {@code Unit} * * @return a new {@code Unit} that is the addition of this {@code Unit} and * the {@code Unit} specified. * * @throws RuntimeException if the two {@code Unit} s are not the same */ Unit add(Unit that) { if (!this.equals(that)) { throw new ArithmeticException("Cannot add " + this + " to " + that); } return this; }