[wpiunits] Restore and deprecate measure negate (#7345)

Delegate to unaryMinus.

This ensures there's a deprecation message to help users with migration, vs just a compile error.
This commit is contained in:
sciencewhiz
2024-11-06 15:07:31 -08:00
committed by GitHub
parent 83fa422338
commit 71c050389a
27 changed files with 197 additions and 0 deletions

View File

@@ -124,6 +124,21 @@ public interface Measure<U extends Unit> extends Comparable<Measure<U>> {
*/
Measure<U> 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 {@code Celsius.of(10).negate()} returns a value
* equivalent to -10 Kelvin, and <i>not</i> -10° Celsius.
*
* @return a measure equal to zero minus this measure
* @deprecated use unaryMinus() instead. This was renamed for consistancy with other WPILib
* classes like Rotation2d
*/
@Deprecated(since = "2025", forRemoval = true)
default Measure<U> negate() {
return unaryMinus();
}
/**
* Adds another measure of the same unit type to this one.
*