mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-26 01:51:41 +00:00
[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:
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user