2024-09-07 13:59:29 -04:00
|
|
|
// Copyright (c) FIRST and other WPILib contributors.
|
|
|
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
|
|
|
// the WPILib BSD license file in the root directory of this project.
|
|
|
|
|
|
|
|
|
|
// THIS FILE WAS AUTO-GENERATED BY ./wpiunits/generate_units.py. DO NOT MODIFY
|
|
|
|
|
|
|
|
|
|
package edu.wpi.first.units.measure;
|
|
|
|
|
|
|
|
|
|
import static edu.wpi.first.units.Units.*;
|
|
|
|
|
import edu.wpi.first.units.*;
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings({"unchecked", "cast", "checkstyle", "PMD"})
|
|
|
|
|
public interface {{ helpers['type_decl'](name) }} extends Measure<{{ helpers['mtou'](name) }}> {
|
|
|
|
|
static {{ helpers['generics_list'](name) }} {{ helpers['type_usage'](name) }} ofRelativeUnits(double magnitude, {{ helpers['mtou'](name) }} unit) {
|
|
|
|
|
return new Immutable{{ helpers['type_usage'](name) }}(magnitude, unit.toBaseUnits(magnitude), unit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static {{ helpers['generics_list'](name) }} {{ helpers['type_usage'](name) }} ofBaseUnits(double baseUnitMagnitude, {{ helpers['mtou'](name) }} unit) {
|
|
|
|
|
return new Immutable{{ helpers['type_usage'](name) }}(unit.fromBaseUnits(baseUnitMagnitude), baseUnitMagnitude, unit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
{{ helpers['type_usage'](name) }} copy();
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
default Mut{{ helpers['type_usage'](name) }} mutableCopy() {
|
|
|
|
|
return new Mut{{ helpers['type_usage'](name) }}(magnitude(), baseUnitMagnitude(), unit());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
{{ helpers['mtou'](name) }} unit();
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
default {{ helpers['mtou'](name) }} baseUnit() { return ({{ helpers['mtou'](name) }}) unit().getBaseUnit(); }
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
default double in({{ helpers['mtou'](name) }} unit) {
|
|
|
|
|
return unit.fromBaseUnits(baseUnitMagnitude());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
default {{ helpers['type_usage'](name) }} unaryMinus() {
|
|
|
|
|
return ({{ helpers['type_usage'](name) }}) unit().ofBaseUnits(0 - baseUnitMagnitude());
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-27 23:03:23 -08:00
|
|
|
/**
|
|
|
|
|
* {@inheritDoc}
|
|
|
|
|
*
|
|
|
|
|
* @deprecated use unaryMinus() instead. This was renamed for consistency with other WPILib classes like Rotation2d
|
|
|
|
|
*/
|
2024-11-06 15:07:31 -08:00
|
|
|
@Override
|
|
|
|
|
@Deprecated(since = "2025", forRemoval = true)
|
|
|
|
|
@SuppressWarnings({"deprecation", "removal"})
|
|
|
|
|
default {{ helpers['type_usage'](name) }} negate() {
|
|
|
|
|
return ({{ helpers['type_usage'](name) }}) unaryMinus();
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-07 13:59:29 -04:00
|
|
|
@Override
|
|
|
|
|
default {{ helpers['type_usage'](name) }} plus(Measure<? extends {{ helpers['mtou'](name) }}> other) {
|
|
|
|
|
return ({{ helpers['type_usage'](name) }}) unit().ofBaseUnits(baseUnitMagnitude() + other.baseUnitMagnitude());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
default {{ helpers['type_usage'](name) }} minus(Measure<? extends {{ helpers['mtou'](name) }}> other) {
|
|
|
|
|
return ({{ helpers['type_usage'](name) }}) unit().ofBaseUnits(baseUnitMagnitude() - other.baseUnitMagnitude());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
default {{ helpers['type_usage'](name) }} times(double multiplier) {
|
|
|
|
|
return ({{ helpers['type_usage'](name) }}) unit().ofBaseUnits(baseUnitMagnitude() * multiplier);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2024-11-15 13:49:40 -05:00
|
|
|
default {{ helpers['type_usage'](name) }} div(double divisor) {
|
2024-09-07 13:59:29 -04:00
|
|
|
return ({{ helpers['type_usage'](name) }}) unit().ofBaseUnits(baseUnitMagnitude() / divisor);
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-27 23:01:26 -08:00
|
|
|
/**
|
|
|
|
|
* {@inheritDoc}
|
|
|
|
|
*
|
|
|
|
|
* @deprecated use div instead. This was renamed for consistency with other languages like Kotlin
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@Deprecated(since = "2025", forRemoval = true)
|
|
|
|
|
@SuppressWarnings({"deprecation", "removal"})
|
|
|
|
|
default {{ helpers['type_usage'](name) }} divide(double divisor) {
|
|
|
|
|
return ({{ helpers['type_usage'](name) }}) div(divisor);
|
|
|
|
|
}
|
2024-09-07 13:59:29 -04:00
|
|
|
{% for unit in math_units -%}
|
|
|
|
|
{% if unit == "Dimensionless" %}
|
|
|
|
|
@Override
|
2024-11-15 13:49:40 -05:00
|
|
|
default {{ helpers['type_usage'](name) }} div({{ unit }} divisor) {
|
2024-09-07 13:59:29 -04:00
|
|
|
return ({{ helpers['type_usage'](name) }}) {{ config[name]['base_unit'] }}.of(baseUnitMagnitude() / divisor.baseUnitMagnitude());
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-27 23:01:26 -08:00
|
|
|
/**
|
|
|
|
|
* {@inheritDoc}
|
|
|
|
|
*
|
|
|
|
|
* @deprecated use div instead. This was renamed for consistency with other languages like Kotlin
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@Deprecated(since = "2025", forRemoval = true)
|
|
|
|
|
@SuppressWarnings({"deprecation", "removal"})
|
|
|
|
|
default {{ helpers['type_usage'](name) }} divide({{ unit }} divisor) {
|
|
|
|
|
return ({{ helpers['type_usage'](name) }}) div(divisor);
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-07 13:59:29 -04:00
|
|
|
@Override
|
|
|
|
|
default {{ helpers['type_usage'](name) }} times({{ unit }} multiplier) {
|
|
|
|
|
return ({{ helpers['type_usage'](name) }}) {{ config[name]['base_unit'] }}.of(baseUnitMagnitude() * multiplier.baseUnitMagnitude());
|
|
|
|
|
}
|
|
|
|
|
{% else %}
|
|
|
|
|
{% if unit in config[name]['multiply'] %}
|
2024-10-04 01:19:36 -04:00
|
|
|
{%- if 'implementation' in config[name]['multiply'][unit] -%}
|
|
|
|
|
{{ helpers['indent'](config[name]['multiply'][unit]['implementation'], 2) }}
|
|
|
|
|
{%- else %}
|
2024-09-07 13:59:29 -04:00
|
|
|
@Override
|
|
|
|
|
default {{ config[name]['multiply'][unit] }} times({{ unit }} multiplier) {
|
|
|
|
|
return {{ config[config[name]['multiply'][unit]]['base_unit'] }}.of(baseUnitMagnitude() * multiplier.baseUnitMagnitude());
|
|
|
|
|
}
|
2024-10-04 01:19:36 -04:00
|
|
|
{%- endif %}
|
2024-09-07 13:59:29 -04:00
|
|
|
{% else %}
|
|
|
|
|
@Override
|
|
|
|
|
default Mult<{{ helpers['mtou'](name) }}, {{ helpers['mtou'](unit) }}> times({{ unit }} multiplier) {
|
|
|
|
|
return (Mult<{{ helpers['mtou'](name) }}, {{ helpers['mtou'](unit) }}>) Measure.super.times(multiplier);
|
|
|
|
|
}
|
|
|
|
|
{% endif -%}
|
|
|
|
|
{% if unit in config[name]['divide'] %}
|
|
|
|
|
@Override
|
2024-11-15 13:49:40 -05:00
|
|
|
default {{ config[name]['divide'][unit] }} div({{ unit }} divisor) {
|
2024-09-07 13:59:29 -04:00
|
|
|
return {{ config[config[name]['divide'][unit]]['base_unit'] }}.of(baseUnitMagnitude() / divisor.baseUnitMagnitude());
|
|
|
|
|
}
|
2024-11-27 23:01:26 -08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* {@inheritDoc}
|
|
|
|
|
*
|
|
|
|
|
* @deprecated use div instead. This was renamed for consistency with other languages like Kotlin
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@Deprecated(since = "2025", forRemoval = true)
|
|
|
|
|
@SuppressWarnings({"deprecation", "removal"})
|
|
|
|
|
default {{ config[name]['divide'][unit] }} divide({{ unit }} divisor) {
|
|
|
|
|
return div(divisor);
|
|
|
|
|
}
|
2025-01-17 02:24:11 -05:00
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
default {{ config[name]['divide'][unit] }} per({{ helpers['mtou'](unit) }} divisorUnit) {
|
|
|
|
|
{%- if unit == "Mult<?, ?>" or unit == "Per<?, ?>" %}
|
|
|
|
|
return div(divisorUnit.ofNative(1));
|
|
|
|
|
{%- else %}
|
|
|
|
|
return div(divisorUnit.one());
|
|
|
|
|
{%- endif %}
|
|
|
|
|
}
|
2024-09-07 13:59:29 -04:00
|
|
|
{% elif unit == "Time" %}
|
|
|
|
|
@Override
|
2024-11-15 13:49:40 -05:00
|
|
|
default Velocity<{{ helpers['mtou'](name) }}> div({{ unit }} divisor) {
|
2024-09-07 13:59:29 -04:00
|
|
|
return VelocityUnit.combine(unit(), divisor.unit()).ofBaseUnits(baseUnitMagnitude() / divisor.baseUnitMagnitude());
|
|
|
|
|
}
|
2024-11-27 23:01:26 -08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* {@inheritDoc}
|
|
|
|
|
*
|
|
|
|
|
* @deprecated use div instead. This was renamed for consistency with other languages like Kotlin
|
|
|
|
|
*/
|
|
|
|
|
@Deprecated(since = "2025", forRemoval = true)
|
|
|
|
|
@SuppressWarnings({"deprecation", "removal"})
|
|
|
|
|
@Override
|
|
|
|
|
default Velocity<{{ helpers['mtou'](name) }}> divide({{ unit }} divisor) {
|
|
|
|
|
return div(divisor);
|
|
|
|
|
}
|
2025-01-17 02:24:11 -05:00
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
default Velocity<{{ helpers['mtou'](name) }}> per({{ helpers['mtou'](unit) }} divisorUnit) {
|
|
|
|
|
{%- if unit == "Mult<?, ?>" or unit == "Per<?, ?>" %}
|
|
|
|
|
return div(divisorUnit.ofNative(1));
|
|
|
|
|
{%- else %}
|
|
|
|
|
return div(divisorUnit.one());
|
|
|
|
|
{%- endif %}
|
|
|
|
|
}
|
2024-09-07 13:59:29 -04:00
|
|
|
{% elif unit == name %}
|
|
|
|
|
@Override
|
2024-11-15 13:49:40 -05:00
|
|
|
default Dimensionless div({{ unit }} divisor) {
|
2024-09-07 13:59:29 -04:00
|
|
|
return Value.of(baseUnitMagnitude() / divisor.baseUnitMagnitude());
|
|
|
|
|
}
|
2024-11-27 23:01:26 -08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* {@inheritDoc}
|
|
|
|
|
*
|
|
|
|
|
* @deprecated use div instead. This was renamed for consistency with other languages like Kotlin
|
|
|
|
|
*/
|
|
|
|
|
@Deprecated(since = "2025", forRemoval = true)
|
|
|
|
|
@SuppressWarnings({"deprecation", "removal"})
|
|
|
|
|
@Override
|
|
|
|
|
default Dimensionless divide({{ unit }} divisor) {
|
|
|
|
|
return div(divisor);
|
|
|
|
|
}
|
2025-01-17 02:24:11 -05:00
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
default Dimensionless per({{ helpers['mtou'](unit) }} divisorUnit) {
|
|
|
|
|
return div(divisorUnit.one());
|
|
|
|
|
}
|
2024-09-07 13:59:29 -04:00
|
|
|
{% else %}
|
|
|
|
|
@Override
|
2024-11-15 13:49:40 -05:00
|
|
|
default Per<{{ helpers['mtou'](name) }}, {{ helpers['mtou'](unit) }}> div({{ unit }} divisor) {
|
|
|
|
|
return (Per<{{ helpers['mtou'](name) }}, {{ helpers['mtou'](unit) }}>) Measure.super.div(divisor);
|
2024-09-07 13:59:29 -04:00
|
|
|
}
|
2024-11-27 23:01:26 -08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* {@inheritDoc}
|
|
|
|
|
*
|
|
|
|
|
* @deprecated use div instead. This was renamed for consistency with other languages like Kotlin
|
|
|
|
|
*/
|
|
|
|
|
@Deprecated(since = "2025", forRemoval = true)
|
|
|
|
|
@SuppressWarnings({"deprecation", "removal"})
|
|
|
|
|
@Override
|
|
|
|
|
default Per<{{ helpers['mtou'](name) }}, {{ helpers['mtou'](unit) }}> divide({{ unit }} divisor) {
|
|
|
|
|
return div(divisor);
|
|
|
|
|
}
|
2025-01-17 02:24:11 -05:00
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
default Per<{{ helpers['mtou'](name) }}, {{ helpers['mtou'](unit) }}> per({{ helpers['mtou'](unit) }} divisorUnit) {
|
|
|
|
|
{%- if unit == "Mult<?, ?>" or unit == "Per<?, ?>" %}
|
|
|
|
|
return div(divisorUnit.ofNative(1));
|
|
|
|
|
{%- else %}
|
|
|
|
|
return div(divisorUnit.one());
|
|
|
|
|
{%- endif %}
|
|
|
|
|
}
|
2024-09-07 13:59:29 -04:00
|
|
|
{% endif -%}
|
|
|
|
|
{% endif -%}
|
|
|
|
|
{% endfor -%}
|
|
|
|
|
{{ config[name]['extra'] }}
|
|
|
|
|
}
|