Interface Measure<U extends Unit>

Type Parameters:
U - the unit type of the measure
All Superinterfaces:
Comparable<Measure<U>>
All Known Subinterfaces:
Acceleration<D>, Angle, AngularAcceleration, AngularMomentum, AngularVelocity, Current, Dimensionless, Distance, Energy, Force, Frequency, LinearAcceleration, LinearMomentum, LinearVelocity, Mass, MomentOfInertia, Mult<A,B>, MutableMeasure<U,Base,MutSelf>, Per<Dividend,Divisor>, Power, Resistance, Temperature, Time, Torque, Velocity<D>, Voltage
All Known Implementing Classes:
GenericMutableMeasureImpl, ImmutableAcceleration, ImmutableAngle, ImmutableAngularAcceleration, ImmutableAngularMomentum, ImmutableAngularVelocity, ImmutableCurrent, ImmutableDimensionless, ImmutableDistance, ImmutableEnergy, ImmutableForce, ImmutableFrequency, ImmutableLinearAcceleration, ImmutableLinearMomentum, ImmutableLinearVelocity, ImmutableMass, ImmutableMeasure, ImmutableMomentOfInertia, ImmutableMult, ImmutablePer, ImmutablePower, ImmutableResistance, ImmutableTemperature, ImmutableTime, ImmutableTorque, ImmutableVelocity, ImmutableVoltage, MutableMeasureBase, MutAcceleration, MutAngle, MutAngularAcceleration, MutAngularMomentum, MutAngularVelocity, MutCurrent, MutDimensionless, MutDistance, MutEnergy, MutForce, MutFrequency, MutLinearAcceleration, MutLinearMomentum, MutLinearVelocity, MutMass, MutMomentOfInertia, MutMult, MutPer, MutPower, MutResistance, MutTemperature, MutTime, MutTorque, MutVelocity, MutVoltage

public interface Measure<U extends Unit> extends Comparable<Measure<U>>
A measure holds the magnitude and unit of some dimension, such as distance, time, or speed. Two measures with the same unit and magnitude are effectively equivalent objects.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double
    The threshold for two measures to be considered equivalent if converted to the same unit.
  • Method Summary

    Modifier and Type
    Method
    Description
    default double
    abs(U unit)
    Absolute value of measure.
    default U
    A convenience method to get the base unit of the measurement.
    double
    Gets the magnitude of this measure in terms of the base unit.
    default int
    Returns an immutable copy of this measure.
    default double
    copySign(Measure<U> other, U unit)
    Take the sign of another measure.
    div(double divisor)
    Divides this measure by a unitless scalar and returns the result.
    default Measure<?>
    div(Acceleration<?> divisor)
    Divides this measure by a generic acceleration and returns the result in the most appropriate unit.
    default Measure<?>
    div(Angle divisor)
    Divides this measure by an angle and returns the result in the most appropriate unit.
    default Measure<?>
    Divides this measure by an angular acceleration and returns the result in the most appropriate unit.
    default Measure<?>
    Divides this measure by an angular momentum and returns the result in the most appropriate unit.
    default Measure<?>
    Divides this measure by an angular velocity and returns the result in the most appropriate unit.
    default Measure<?>
    div(Current divisor)
    Divides this measure by an electric current and returns the result in the most appropriate unit.
    div(Dimensionless divisor)
    Divides this measure by a dimensionless scalar and returns the result.
    default Measure<?>
    div(Distance divisor)
    Divides this measure by a distance and returns the result in the most appropriate unit.
    default Measure<?>
    div(Energy divisor)
    Divides this measure by an energy and returns the result in the most appropriate unit.
    default Measure<?>
    div(Force divisor)
    Divides this measure by a force and returns the result in the most appropriate unit.
    default Measure<?>
    div(Frequency divisor)
    Divides this measure by a frequency and returns the result in the most appropriate unit.
    default Measure<?>
    Divides this measure by a linear acceleration and returns the result in the most appropriate unit.
    default Measure<?>
    Divides this measure by a linear momentum and returns the result in the most appropriate unit.
    default Measure<?>
    Divides this measure by a linear velocity and returns the result in the most appropriate unit.
    default Measure<?>
    div(Mass divisor)
    Divides this measure by a mass and returns the result in the most appropriate unit.
    default Measure<?>
    Divides this measure by a moment of inertia and returns the result in the most appropriate unit.
    default Measure<?>
    div(Mult<?,?> divisor)
    Divides this measure by a generic multiplication and returns the result in the most appropriate unit.
    default Measure<?>
    div(Per<?,?> divisor)
    Divides this measure by a generic ratio and returns the result in the most appropriate unit.
    default Measure<?>
    div(Power divisor)
    Divides this measure by a power and returns the result in the most appropriate unit.
    default Measure<?>
    div(Resistance divisor)
    Divides this measure by a resistance and returns the result in the most appropriate unit.
    default Measure<?>
    div(Temperature divisor)
    Divides this measure by a temperature and returns the result in the most appropriate unit.
    default Measure<?>
    div(Time divisor)
    Divides this measure by a time and returns the result in the most appropriate unit.
    default Measure<?>
    div(Torque divisor)
    Divides this measure by a torque and returns the result in the most appropriate unit.
    default Measure<?>
    div(Velocity<?> divisor)
    Divides this measure by a generic velocity and returns the result in the most appropriate unit.
    default Measure<?>
    div(Voltage divisor)
    Divides this measure by a voltage and returns the result in the most appropriate unit.
    default Measure<?>
    div(Measure<?> divisor)
    Divides this measurement by another measure and performs some dimensional analysis to reduce the units.
    default Measure<U>
    divide(double divisor)
    Deprecated, for removal: This API element is subject to removal in a future version.
    use div instead.
    default Measure<?>
    divide(Acceleration<?> divisor)
    Deprecated, for removal: This API element is subject to removal in a future version.
    use div instead.
    default Measure<?>
    divide(Angle divisor)
    Deprecated, for removal: This API element is subject to removal in a future version.
    use div instead.
    default Measure<?>
    Deprecated, for removal: This API element is subject to removal in a future version.
    use div instead.
    default Measure<?>
    Deprecated, for removal: This API element is subject to removal in a future version.
    use div instead.
    default Measure<?>
    Deprecated, for removal: This API element is subject to removal in a future version.
    use div instead.
    default Measure<?>
    divide(Current divisor)
    Deprecated, for removal: This API element is subject to removal in a future version.
    use div instead.
    default Measure<U>
    Deprecated, for removal: This API element is subject to removal in a future version.
    use div instead.
    default Measure<?>
    divide(Distance divisor)
    Deprecated, for removal: This API element is subject to removal in a future version.
    use div instead.
    default Measure<?>
    divide(Energy divisor)
    Deprecated, for removal: This API element is subject to removal in a future version.
    use div instead.
    default Measure<?>
    divide(Force divisor)
    Deprecated, for removal: This API element is subject to removal in a future version.
    use div instead.
    default Measure<?>
    divide(Frequency divisor)
    Deprecated, for removal: This API element is subject to removal in a future version.
    use div instead.
    default Measure<?>
    Deprecated, for removal: This API element is subject to removal in a future version.
    use div instead.
    default Measure<?>
    Deprecated, for removal: This API element is subject to removal in a future version.
    use div instead.
    default Measure<?>
    Deprecated, for removal: This API element is subject to removal in a future version.
    use div instead.
    default Measure<?>
    divide(Mass divisor)
    Deprecated, for removal: This API element is subject to removal in a future version.
    use div instead.
    default Measure<?>
    Deprecated, for removal: This API element is subject to removal in a future version.
    use div instead.
    default Measure<?>
    divide(Mult<?,?> divisor)
    Deprecated, for removal: This API element is subject to removal in a future version.
    use div instead.
    default Measure<?>
    divide(Per<?,?> divisor)
    Deprecated, for removal: This API element is subject to removal in a future version.
    use div instead.
    default Measure<?>
    divide(Power divisor)
    Deprecated, for removal: This API element is subject to removal in a future version.
    use div instead.
    default Measure<?>
    divide(Resistance divisor)
    Deprecated, for removal: This API element is subject to removal in a future version.
    use div instead.
    default Measure<?>
    Deprecated, for removal: This API element is subject to removal in a future version.
    use div instead.
    default Measure<?>
    divide(Time divisor)
    Deprecated, for removal: This API element is subject to removal in a future version.
    use div instead.
    default Measure<?>
    divide(Torque divisor)
    Deprecated, for removal: This API element is subject to removal in a future version.
    use div instead.
    default Measure<?>
    divide(Velocity<?> divisor)
    Deprecated, for removal: This API element is subject to removal in a future version.
    use div instead.
    default Measure<?>
    divide(Voltage divisor)
    Deprecated, for removal: This API element is subject to removal in a future version.
    use div instead.
    default Measure<?>
    divide(Measure<?> divisor)
    Deprecated, for removal: This API element is subject to removal in a future version.
    use div instead.
    default <Other extends Unit>
    Measure<Other>
    divideRatio(Measure<? extends PerUnit<? extends U,Other>> divisor)
    Divides this measure by a ratio in terms of this measurement's unit to another unit, returning a measurement in terms of the other unit.
    default boolean
    gt(Measure<U> o)
    Checks if this measure is greater than another measure of the same unit.
    default boolean
    Checks if this measure is greater than or equivalent to another measure of the same unit.
    default double
    in(U unit)
    Converts this measure to a measure with a different unit of the same type, eg minutes to seconds.
    default boolean
    Checks if this measure is equivalent to another measure of the same unit.
    default boolean
    isNear(Measure<?> other, double varianceThreshold)
    Checks if this measure is near another measure of the same unit.
    default boolean
    isNear(Measure<U> other, Measure<U> tolerance)
    Checks if this measure is near another measure of the same unit, with a specified tolerance of the same unit.
    default boolean
    lt(Measure<U> o)
    Checks if this measure is less than another measure of the same unit.
    default boolean
    Checks if this measure is less than or equivalent to another measure of the same unit.
    double
    Gets the unitless magnitude of this measure.
    static <U extends Unit>
    Measure<U>
    max(Measure<U>... measures)
    Returns the measure with the absolute value closest to positive infinity.
    static <U extends Unit>
    Measure<U>
    min(Measure<U>... measures)
    Returns the measure with the absolute value closest to negative infinity.
    minus(Measure<? extends U> other)
    Subtracts another measure of the same unit type from this one.
    Returns a mutable copy of this measure.
    default Measure<U>
    Deprecated, for removal: This API element is subject to removal in a future version.
    use unaryMinus() instead.
    default Measure<?>
    per(TimeUnit period)
    Divides this measure by a time period and returns the result in the most appropriate unit.
    plus(Measure<? extends U> other)
    Adds another measure of the same unit type to this one.
    times(double multiplier)
    Multiplies this measure by a scalar unitless multiplier.
    default Measure<?>
    times(Acceleration<?> multiplier)
    Multiplies this measure by an acceleration and returns the resulting measure in the most appropriate unit.
    default Measure<?>
    times(Angle multiplier)
    Multiplies this measure by an angle and returns the resulting measure in the most appropriate unit.
    default Measure<?>
    Multiplies this measure by an angular acceleration and returns the resulting measure in the most appropriate unit.
    default Measure<?>
    times(AngularMomentum multiplier)
    Multiplies this measure by an angular momentum and returns the resulting measure in the most appropriate unit.
    default Measure<?>
    times(AngularVelocity multiplier)
    Multiplies this measure by an angular velocity and returns the resulting measure in the most appropriate unit.
    default Measure<?>
    times(Current multiplier)
    Multiplies this measure by an electric current and returns the resulting measure in the most appropriate unit.
    times(Dimensionless multiplier)
    Multiplies this measure by a scalar dimensionless multiplier.
    default Measure<?>
    times(Distance multiplier)
    Multiplies this measure by a distance and returns the resulting measure in the most appropriate unit.
    default Measure<?>
    times(Energy multiplier)
    Multiplies this measure by an energy and returns the resulting measure in the most appropriate unit.
    default Measure<?>
    times(Force multiplier)
    Multiplies this measure by a force and returns the resulting measure in the most appropriate unit.
    default Measure<?>
    times(Frequency multiplier)
    Multiplies this measure by a frequency and returns the resulting measure in the most appropriate unit.
    default Measure<?>
    Multiplies this measure by a linear acceleration and returns the resulting measure in the most appropriate unit.
    default Measure<?>
    times(LinearMomentum multiplier)
    Multiplies this measure by a linear momentum and returns the resulting measure in the most appropriate unit.
    default Measure<?>
    times(LinearVelocity multiplier)
    Multiplies this measure by a linear velocity and returns the resulting measure in the most appropriate unit.
    default Measure<?>
    times(Mass multiplier)
    Multiplies this measure by a mass and returns the resulting measure in the most appropriate unit.
    default Measure<?>
    times(MomentOfInertia multiplier)
    Multiplies this measure by a moment of intertia and returns the resulting measure in the most appropriate unit.
    default Measure<?>
    times(Mult<?,?> multiplier)
    Multiplies this measure by a generic multiplied measure and returns the resulting measure in the most appropriate unit.
    default Measure<?>
    times(Per<?,?> multiplier)
    Multiplies this measure by a generic ratio measurement and returns the resulting measure in the most appropriate unit.
    default Measure<?>
    times(Power multiplier)
    Multiplies this measure by a power and returns the resulting measure in the most appropriate unit.
    default Measure<?>
    times(Resistance multiplier)
    Multiplies this measure by a resistance and returns the resulting measure in the most appropriate unit.
    default Measure<?>
    times(Temperature multiplier)
    Multiplies this measure by a temperature and returns the resulting measure in the most appropriate unit.
    default Measure<?>
    times(Time multiplier)
    Multiplies this measure by a time and returns the resulting measure in the most appropriate unit.
    default Measure<?>
    times(Torque multiplier)
    Multiplies this measure by a torque and returns the resulting measure in the most appropriate unit.
    default Measure<?>
    times(Velocity<?> multiplier)
    Multiplies this measure by a generic velocity and returns the resulting measure in the most appropriate unit.
    default Measure<?>
    times(Voltage multiplier)
    Multiplies this measure by a voltage and returns the resulting measure in the most appropriate unit.
    default Measure<?>
    times(Measure<?> multiplier)
    Generates a new measure that is equal to this measure multiplied by another.
    default <Other extends Unit, M extends Measure<Other>>
    M
    timesConversionFactor(Measure<? extends PerUnit<Other,U>> conversionFactor)
    Multiplies this measure by a conversion factor, returning the converted measurement.
    timesInverse(Measure<? extends PerUnit<DimensionlessUnit,? extends U>> multiplier)
    Multiplies this measure by another measurement of the inverse unit type (eg Time multiplied by Frequency) and returns the resulting dimensionless measure.
    default <Other extends Unit>
    Measure<Other>
    timesRatio(Measure<? extends PerUnit<? extends Other,U>> ratio)
    Multiplies this measure by another measurement of something over the unit type (eg Time multiplied by LinearVelocity) and returns the resulting measure of the ratio's dividend unit.
    default String
    Returns a string representation of this measurement in a longhand form.
    default String
    Returns a string representation of this measurement in a shorthand form.
    Returns a measure equivalent to this one equal to zero minus its current value.
    Gets the units of this measure.
  • Field Details

    • EQUIVALENCE_THRESHOLD

      static final double EQUIVALENCE_THRESHOLD
      The threshold for two measures to be considered equivalent if converted to the same unit. This is only needed due to floating-point error.
      See Also:
  • Method Details

    • magnitude

      double magnitude()
      Gets the unitless magnitude of this measure.
      Returns:
      the magnitude in terms of the unit.
    • baseUnitMagnitude

      Gets the magnitude of this measure in terms of the base unit. If the unit is the base unit for its system of measure, then the value will be equivalent to magnitude().
      Returns:
      the magnitude in terms of the base unit
    • unit

      U unit()
      Gets the units of this measure.
      Returns:
      the unit
    • in

      default double in(U unit)
      Converts this measure to a measure with a different unit of the same type, eg minutes to seconds. Converting to the same unit is equivalent to calling magnitude().
         Meters.of(12).in(Feet) // 39.3701
         Seconds.of(15).in(Minutes) // 0.25
       
      Parameters:
      unit - the unit to convert this measure to
      Returns:
      the value of this measure in the given unit
    • baseUnit

      default U baseUnit()
      A convenience method to get the base unit of the measurement. Equivalent to unit().getBaseUnit().
      Returns:
      the base unit of measure.
    • abs

      default double abs(U unit)
      Absolute value of measure.
      Parameters:
      unit - unit to use
      Returns:
      the absolute value of this measure in the given unit
    • copySign

      default double copySign(Measure<U> other, U unit)
      Take the sign of another measure.
      Parameters:
      other - measure from which to take sign
      unit - unit to use
      Returns:
      the value of the measure in the given unit with the sign of the provided measure
    • copy

      Returns an immutable copy of this measure. The copy can be used freely and is guaranteed never to change.
      Returns:
      the copied measure
    • mutableCopy

      Returns a mutable copy of this measure. It will be initialized to the current state of this measure, but can be changed over time without needing to allocate new measurement objects.
      Returns:
      the copied measure
    • unaryMinus

      Returns a measure equivalent to this one equal to zero minus its current value. For non-linear unit types like temperature, the zero point is treated as the zero value of the base unit (eg Kelvin). In effect, this means code like Celsius.of(10).unaryMinus() returns a value equivalent to -10 Kelvin, and not -10° Celsius.
      Returns:
      a measure equal to zero minus this measure
    • negate

      @Deprecated(since="2025", forRemoval=true) default Measure<U> negate()
      Deprecated, for removal: This API element is subject to removal in a future version.
      use unaryMinus() instead. This was renamed for consistency with other WPILib classes like Rotation2d
      Returns a measure equivalent to this one equal to zero minus its current value. For non-linear unit types like temperature, the zero point is treated as the zero value of the base unit (eg Kelvin). In effect, this means code like Celsius.of(10).negate() returns a value equivalent to -10 Kelvin, and not -10° Celsius.
      Returns:
      a measure equal to zero minus this measure
    • plus

      Measure<U> plus(Measure<? extends U> other)
      Adds another measure of the same unit type to this one.
      Parameters:
      other - the measurement to add
      Returns:
      a measure of the sum of both measures
    • minus

      Measure<U> minus(Measure<? extends U> other)
      Subtracts another measure of the same unit type from this one.
      Parameters:
      other - the measurement to subtract
      Returns:
      a measure of the difference between the measures
    • times

      Measure<U> times(double multiplier)
      Multiplies this measure by a scalar unitless multiplier.
      Parameters:
      multiplier - the scalar multiplication factor
      Returns:
      the scaled result
    • times

      Measure<U> times(Dimensionless multiplier)
      Multiplies this measure by a scalar dimensionless multiplier.
      Parameters:
      multiplier - the scalar multiplication factor
      Returns:
      the scaled result
    • times

      default Measure<?> times(Measure<?> multiplier)
      Generates a new measure that is equal to this measure multiplied by another. Some dimensional analysis is performed to reduce the units down somewhat; for example, multiplying a Measure<Time> by a Measure<Velocity<Distance>> will return just a Measure<Distance> instead of the naive Measure<Mult<Time, Velocity<Distance>>. This is not guaranteed to perform perfect dimensional analysis.
      Parameters:
      multiplier - the unit to multiply by
      Returns:
      the multiplicative unit
    • times

      default Measure<?> times(Acceleration<?> multiplier)
      Multiplies this measure by an acceleration and returns the resulting measure in the most appropriate unit.
      Parameters:
      multiplier - the measurement to multiply by.
      Returns:
      the multiplication result
    • times

      default Measure<?> times(Angle multiplier)
      Multiplies this measure by an angle and returns the resulting measure in the most appropriate unit.
      Parameters:
      multiplier - the measurement to multiply by.
      Returns:
      the multiplication result
    • times

      default Measure<?> times(AngularAcceleration multiplier)
      Multiplies this measure by an angular acceleration and returns the resulting measure in the most appropriate unit.
      Parameters:
      multiplier - the measurement to multiply by.
      Returns:
      the multiplication result
    • times

      default Measure<?> times(AngularMomentum multiplier)
      Multiplies this measure by an angular momentum and returns the resulting measure in the most appropriate unit.
      Parameters:
      multiplier - the measurement to multiply by.
      Returns:
      the multiplication result
    • times

      default Measure<?> times(AngularVelocity multiplier)
      Multiplies this measure by an angular velocity and returns the resulting measure in the most appropriate unit.
      Parameters:
      multiplier - the measurement to multiply by.
      Returns:
      the multiplication result
    • times

      default Measure<?> times(Current multiplier)
      Multiplies this measure by an electric current and returns the resulting measure in the most appropriate unit.
      Parameters:
      multiplier - the measurement to multiply by.
      Returns:
      the multiplication result
    • times

      default Measure<?> times(Distance multiplier)
      Multiplies this measure by a distance and returns the resulting measure in the most appropriate unit.
      Parameters:
      multiplier - the measurement to multiply by.
      Returns:
      the multiplication result
    • times

      default Measure<?> times(Energy multiplier)
      Multiplies this measure by an energy and returns the resulting measure in the most appropriate unit.
      Parameters:
      multiplier - the measurement to multiply by.
      Returns:
      the multiplication result
    • times

      default Measure<?> times(Force multiplier)
      Multiplies this measure by a force and returns the resulting measure in the most appropriate unit.
      Parameters:
      multiplier - the measurement to multiply by.
      Returns:
      the multiplication result
    • times

      default Measure<?> times(Frequency multiplier)
      Multiplies this measure by a frequency and returns the resulting measure in the most appropriate unit. This often - but not always - means implementations return a variation of a Per measure.
      Parameters:
      multiplier - the measurement to multiply by.
      Returns:
      the multiplication result
    • times

      default Measure<?> times(LinearAcceleration multiplier)
      Multiplies this measure by a linear acceleration and returns the resulting measure in the most appropriate unit.
      Parameters:
      multiplier - the measurement to multiply by.
      Returns:
      the multiplication result
    • times

      default Measure<?> times(LinearMomentum multiplier)
      Multiplies this measure by a linear momentum and returns the resulting measure in the most appropriate unit.
      Parameters:
      multiplier - the measurement to multiply by.
      Returns:
      the multiplication result
    • times

      default Measure<?> times(LinearVelocity multiplier)
      Multiplies this measure by a linear velocity and returns the resulting measure in the most appropriate unit.
      Parameters:
      multiplier - the measurement to multiply by.
      Returns:
      the multiplication result
    • times

      default Measure<?> times(Mass multiplier)
      Multiplies this measure by a mass and returns the resulting measure in the most appropriate unit.
      Parameters:
      multiplier - the measurement to multiply by.
      Returns:
      the multiplication result
    • times

      default Measure<?> times(MomentOfInertia multiplier)
      Multiplies this measure by a moment of intertia and returns the resulting measure in the most appropriate unit.
      Parameters:
      multiplier - the measurement to multiply by.
      Returns:
      the multiplication result
    • times

      default Measure<?> times(Mult<?,?> multiplier)
      Multiplies this measure by a generic multiplied measure and returns the resulting measure in the most appropriate unit.
      Parameters:
      multiplier - the measurement to multiply by.
      Returns:
      the multiplication result
    • times

      default Measure<?> times(Power multiplier)
      Multiplies this measure by a power and returns the resulting measure in the most appropriate unit.
      Parameters:
      multiplier - the measurement to multiply by.
      Returns:
      the multiplication result
    • times

      default Measure<?> times(Per<?,?> multiplier)
      Multiplies this measure by a generic ratio measurement and returns the resulting measure in the most appropriate unit.
      Parameters:
      multiplier - the measurement to multiply by.
      Returns:
      the multiplication result
    • times

      default Measure<?> times(Temperature multiplier)
      Multiplies this measure by a temperature and returns the resulting measure in the most appropriate unit.
      Parameters:
      multiplier - the measurement to multiply by.
      Returns:
      the multiplication result
    • times

      default Measure<?> times(Time multiplier)
      Multiplies this measure by a time and returns the resulting measure in the most appropriate unit.
      Parameters:
      multiplier - the measurement to multiply by.
      Returns:
      the multiplication result
    • times

      default Measure<?> times(Torque multiplier)
      Multiplies this measure by a torque and returns the resulting measure in the most appropriate unit.
      Parameters:
      multiplier - the measurement to multiply by.
      Returns:
      the multiplication result
    • times

      default Measure<?> times(Velocity<?> multiplier)
      Multiplies this measure by a generic velocity and returns the resulting measure in the most appropriate unit.
      Parameters:
      multiplier - the measurement to multiply by.
      Returns:
      the multiplication result
    • times

      default Measure<?> times(Voltage multiplier)
      Multiplies this measure by a voltage and returns the resulting measure in the most appropriate unit.
      Parameters:
      multiplier - the measurement to multiply by.
      Returns:
      the multiplication result
    • times

      default Measure<?> times(Resistance multiplier)
      Multiplies this measure by a resistance and returns the resulting measure in the most appropriate unit.
      Parameters:
      multiplier - the measurement to multiply by.
      Returns:
      the multiplication result
    • timesConversionFactor

      default <Other extends Unit, M extends Measure<Other>> M timesConversionFactor(Measure<? extends PerUnit<Other,U>> conversionFactor)
      Multiplies this measure by a conversion factor, returning the converted measurement. Unlike times(Per), this allows for basic unit cancellation to return measurements of a known dimension.
      Type Parameters:
      Other - the unit type to convert to
      M - the concrete return unit type. Note: the conversion factor's numerator unit must return instances of this type from Unit.ofBaseUnits(double)}
      Parameters:
      conversionFactor - the conversion factor by which to multiply
      Returns:
      the converted result
    • timesInverse

      default Dimensionless timesInverse(Measure<? extends PerUnit<DimensionlessUnit,? extends U>> multiplier)
      Multiplies this measure by another measurement of the inverse unit type (eg Time multiplied by Frequency) and returns the resulting dimensionless measure.
      Parameters:
      multiplier - the measurement to multiply by.
      Returns:
      the multiplication result
    • timesRatio

      default <Other extends Unit> Measure<Other> timesRatio(Measure<? extends PerUnit<? extends Other,U>> ratio)
      Multiplies this measure by another measurement of something over the unit type (eg Time multiplied by LinearVelocity) and returns the resulting measure of the ratio's dividend unit.
      Type Parameters:
      Other - other unit that the results are in terms of
      Parameters:
      ratio - the measurement to multiply by.
      Returns:
      the multiplication result
    • div

      Measure<U> div(double divisor)
      Divides this measure by a unitless scalar and returns the result.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • div

      Divides this measure by a dimensionless scalar and returns the result.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • div

      default Measure<?> div(Measure<?> divisor)
      Divides this measurement by another measure and performs some dimensional analysis to reduce the units.
      Parameters:
      divisor - the unit to divide by
      Returns:
      the resulting measure
    • div

      default Measure<?> div(Acceleration<?> divisor)
      Divides this measure by a generic acceleration and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • div

      default Measure<?> div(Angle divisor)
      Divides this measure by an angle and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • div

      default Measure<?> div(AngularAcceleration divisor)
      Divides this measure by an angular acceleration and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • div

      default Measure<?> div(AngularMomentum divisor)
      Divides this measure by an angular momentum and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • div

      default Measure<?> div(AngularVelocity divisor)
      Divides this measure by an angular velocity and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • div

      default Measure<?> div(Current divisor)
      Divides this measure by an electric current and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • div

      default Measure<?> div(Distance divisor)
      Divides this measure by a distance and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • div

      default Measure<?> div(Energy divisor)
      Divides this measure by an energy and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • div

      default Measure<?> div(Force divisor)
      Divides this measure by a force and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • div

      default Measure<?> div(Frequency divisor)
      Divides this measure by a frequency and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • div

      default Measure<?> div(LinearAcceleration divisor)
      Divides this measure by a linear acceleration and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • div

      default Measure<?> div(LinearMomentum divisor)
      Divides this measure by a linear momentum and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • div

      default Measure<?> div(LinearVelocity divisor)
      Divides this measure by a linear velocity and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • div

      default Measure<?> div(Mass divisor)
      Divides this measure by a mass and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • div

      default Measure<?> div(MomentOfInertia divisor)
      Divides this measure by a moment of inertia and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • div

      default Measure<?> div(Mult<?,?> divisor)
      Divides this measure by a generic multiplication and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • div

      default Measure<?> div(Power divisor)
      Divides this measure by a power and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • div

      default Measure<?> div(Per<?,?> divisor)
      Divides this measure by a generic ratio and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • div

      default Measure<?> div(Temperature divisor)
      Divides this measure by a temperature and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • div

      default Measure<?> div(Time divisor)
      Divides this measure by a time and returns the result in the most appropriate unit. This will often - but not always - result in a Per type like LinearVelocity or Acceleration.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • div

      default Measure<?> div(Torque divisor)
      Divides this measure by a torque and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • div

      default Measure<?> div(Velocity<?> divisor)
      Divides this measure by a generic velocity and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • div

      default Measure<?> div(Voltage divisor)
      Divides this measure by a voltage and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • div

      default Measure<?> div(Resistance divisor)
      Divides this measure by a resistance and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • divide

      @Deprecated(since="2025", forRemoval=true) default Measure<U> divide(double divisor)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use div instead. This was renamed for consistency with other languages like Kotlin
      Divides this measure by a unitless scalar and returns the result.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • divide

      @Deprecated(since="2025", forRemoval=true) default Measure<U> divide(Dimensionless divisor)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use div instead. This was renamed for consistency with other languages like Kotlin
      Divides this measure by a dimensionless scalar and returns the result.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • divide

      @Deprecated(since="2025", forRemoval=true) default Measure<?> divide(Measure<?> divisor)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use div instead. This was renamed for consistency with other languages like Kotlin
      Divides this measurement by another measure and performs some dimensional analysis to reduce the units.
      Parameters:
      divisor - the unit to divide by
      Returns:
      the resulting measure
    • divide

      @Deprecated(since="2025", forRemoval=true) default Measure<?> divide(Acceleration<?> divisor)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use div instead. This was renamed for consistency with other languages like Kotlin
      Divides this measure by a generic acceleration and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • divide

      @Deprecated(since="2025", forRemoval=true) default Measure<?> divide(Angle divisor)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use div instead. This was renamed for consistency with other languages like Kotlin
      Divides this measure by an angle and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • divide

      @Deprecated(since="2025", forRemoval=true) default Measure<?> divide(AngularAcceleration divisor)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use div instead. This was renamed for consistency with other languages like Kotlin
      Divides this measure by an angular acceleration and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • divide

      @Deprecated(since="2025", forRemoval=true) default Measure<?> divide(AngularMomentum divisor)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use div instead. This was renamed for consistency with other languages like Kotlin
      Divides this measure by an angular momentum and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • divide

      @Deprecated(since="2025", forRemoval=true) default Measure<?> divide(AngularVelocity divisor)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use div instead. This was renamed for consistency with other languages like Kotlin
      Divides this measure by an angular velocity and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • divide

      @Deprecated(since="2025", forRemoval=true) default Measure<?> divide(Current divisor)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use div instead. This was renamed for consistency with other languages like Kotlin
      Divides this measure by an electric current and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • divide

      @Deprecated(since="2025", forRemoval=true) default Measure<?> divide(Distance divisor)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use div instead. This was renamed for consistency with other languages like Kotlin
      Divides this measure by a distance and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • divide

      @Deprecated(since="2025", forRemoval=true) default Measure<?> divide(Energy divisor)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use div instead. This was renamed for consistency with other languages like Kotlin
      Divides this measure by an energy and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • divide

      @Deprecated(since="2025", forRemoval=true) default Measure<?> divide(Force divisor)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use div instead. This was renamed for consistency with other languages like Kotlin
      Divides this measure by a force and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • divide

      @Deprecated(since="2025", forRemoval=true) default Measure<?> divide(Frequency divisor)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use div instead. This was renamed for consistency with other languages like Kotlin
      Divides this measure by a frequency and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • divide

      @Deprecated(since="2025", forRemoval=true) default Measure<?> divide(LinearAcceleration divisor)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use div instead. This was renamed for consistency with other languages like Kotlin
      Divides this measure by a linear acceleration and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • divide

      @Deprecated(since="2025", forRemoval=true) default Measure<?> divide(LinearMomentum divisor)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use div instead. This was renamed for consistency with other languages like Kotlin
      Divides this measure by a linear momentum and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • divide

      @Deprecated(since="2025", forRemoval=true) default Measure<?> divide(LinearVelocity divisor)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use div instead. This was renamed for consistency with other languages like Kotlin
      Divides this measure by a linear velocity and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • divide

      @Deprecated(since="2025", forRemoval=true) default Measure<?> divide(Mass divisor)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use div instead. This was renamed for consistency with other languages like Kotlin
      Divides this measure by a mass and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • divide

      @Deprecated(since="2025", forRemoval=true) default Measure<?> divide(MomentOfInertia divisor)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use div instead. This was renamed for consistency with other languages like Kotlin
      Divides this measure by a moment of inertia and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • divide

      @Deprecated(since="2025", forRemoval=true) default Measure<?> divide(Mult<?,?> divisor)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use div instead. This was renamed for consistency with other languages like Kotlin
      Divides this measure by a generic multiplication and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • divide

      @Deprecated(since="2025", forRemoval=true) default Measure<?> divide(Power divisor)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use div instead. This was renamed for consistency with other languages like Kotlin
      Divides this measure by a power and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • divide

      @Deprecated(since="2025", forRemoval=true) default Measure<?> divide(Per<?,?> divisor)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use div instead. This was renamed for consistency with other languages like Kotlin
      Divides this measure by a generic ratio and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • divide

      @Deprecated(since="2025", forRemoval=true) default Measure<?> divide(Temperature divisor)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use div instead. This was renamed for consistency with other languages like Kotlin
      Divides this measure by a temperature and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • divide

      @Deprecated(since="2025", forRemoval=true) default Measure<?> divide(Time divisor)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use div instead. This was renamed for consistency with other languages like Kotlin
      Divides this measure by a time and returns the result in the most appropriate unit. This will often - but not always - result in a Per type like LinearVelocity or Acceleration.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • divide

      @Deprecated(since="2025", forRemoval=true) default Measure<?> divide(Torque divisor)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use div instead. This was renamed for consistency with other languages like Kotlin
      Divides this measure by a torque and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • divide

      @Deprecated(since="2025", forRemoval=true) default Measure<?> divide(Velocity<?> divisor)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use div instead. This was renamed for consistency with other languages like Kotlin
      Divides this measure by a generic velocity and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • divide

      @Deprecated(since="2025", forRemoval=true) default Measure<?> divide(Voltage divisor)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use div instead. This was renamed for consistency with other languages like Kotlin
      Divides this measure by a voltage and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • divide

      @Deprecated(since="2025", forRemoval=true) default Measure<?> divide(Resistance divisor)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use div instead. This was renamed for consistency with other languages like Kotlin
      Divides this measure by a resistance and returns the result in the most appropriate unit.
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • divideRatio

      default <Other extends Unit> Measure<Other> divideRatio(Measure<? extends PerUnit<? extends U,Other>> divisor)
      Divides this measure by a ratio in terms of this measurement's unit to another unit, returning a measurement in terms of the other unit.
      Type Parameters:
      Other - the other unit that results are in terms of
      Parameters:
      divisor - the measurement to divide by.
      Returns:
      the division result
    • per

      default Measure<?> per(TimeUnit period)
      Divides this measure by a time period and returns the result in the most appropriate unit. This is equivalent to div(period.of(1)).
      Parameters:
      period - the time period measurement to divide by.
      Returns:
      the division result
    • isNear

      default boolean isNear(Measure<?> other, double varianceThreshold)
      Checks if this measure is near another measure of the same unit. Provide a variance threshold for use for a +/- scalar, such as 0.05 for +/- 5%.
         Inches.of(11).isNear(Inches.of(10), 0.1) // true
         Inches.of(12).isNear(Inches.of(10), 0.1) // false
       
      Parameters:
      other - the other measurement to compare against
      varianceThreshold - the acceptable variance threshold, in terms of an acceptable +/- error range multiplier. Checking if a value is within 10% means a value of 0.1 should be passed; checking if a value is within 1% means a value of 0.01 should be passed, and so on.
      Returns:
      true if this unit is near the other measure, otherwise false
    • isNear

      default boolean isNear(Measure<U> other, Measure<U> tolerance)
      Checks if this measure is near another measure of the same unit, with a specified tolerance of the same unit.
           Meters.of(1).isNear(Meters.of(1.2), Millimeters.of(300)) // true
           Degrees.of(90).isNear(Rotations.of(0.5), Degrees.of(45)) // false
       
      Parameters:
      other - the other measure to compare against.
      tolerance - the tolerance allowed in which the two measures are defined as near each other.
      Returns:
      true if this unit is near the other measure, otherwise false.
    • isEquivalent

      default boolean isEquivalent(Measure<?> other)
      Checks if this measure is equivalent to another measure of the same unit.
      Parameters:
      other - the measure to compare to
      Returns:
      true if this measure is equivalent, false otherwise
    • compareTo

      default int compareTo(Measure<U> o)
      Specified by:
      compareTo in interface Comparable<U extends Unit>
    • gt

      default boolean gt(Measure<U> o)
      Checks if this measure is greater than another measure of the same unit.
      Parameters:
      o - the other measure to compare to
      Returns:
      true if this measure has a greater equivalent magnitude, false otherwise
    • gte

      default boolean gte(Measure<U> o)
      Checks if this measure is greater than or equivalent to another measure of the same unit.
      Parameters:
      o - the other measure to compare to
      Returns:
      true if this measure has an equal or greater equivalent magnitude, false otherwise
    • lt

      default boolean lt(Measure<U> o)
      Checks if this measure is less than another measure of the same unit.
      Parameters:
      o - the other measure to compare to
      Returns:
      true if this measure has a lesser equivalent magnitude, false otherwise
    • lte

      default boolean lte(Measure<U> o)
      Checks if this measure is less than or equivalent to another measure of the same unit.
      Parameters:
      o - the other measure to compare to
      Returns:
      true if this measure has an equal or lesser equivalent magnitude, false otherwise
    • max

      @SafeVarargs static <U extends Unit> Measure<U> max(Measure<U>... measures)
      Returns the measure with the absolute value closest to positive infinity.
      Type Parameters:
      U - the type of the units of the measures
      Parameters:
      measures - the set of measures to compare
      Returns:
      the measure with the greatest positive magnitude, or null if no measures were provided
    • min

      @SafeVarargs static <U extends Unit> Measure<U> min(Measure<U>... measures)
      Returns the measure with the absolute value closest to negative infinity.
      Type Parameters:
      U - the type of the units of the measures
      Parameters:
      measures - the set of measures to compare
      Returns:
      the measure with the greatest negative magnitude
    • toShortString

      default String toShortString()
      Returns a string representation of this measurement in a shorthand form. The symbol of the backing unit is used, rather than the full name, and the magnitude is represented in scientific notation.
      Returns:
      the short form representation of this measurement
    • toLongString

      default String toLongString()
      Returns a string representation of this measurement in a longhand form. The name of the backing unit is used, rather than its symbol, and the magnitude is represented in a full string, not scientific notation. (Very large values may be represented in scientific notation, however)
      Returns:
      the long form representation of this measurement