// 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. package edu.wpi.first.units; import edu.wpi.first.units.measure.Mass; /** * Unit of mass dimension. * *
This is the base type for units of mass dimension. It is also used to specify the dimension * for the mass-specific {@link Mass} measurement type. * *
Actual units (such as {@link Units#Grams} and {@link Units#Pounds}) can be found in the {@link
* Units} class.
*/
public final class MassUnit extends Unit {
/** Creates a new unit with the given name and multiplier to the base unit. */
MassUnit(MassUnit baseUnit, double baseUnitEquivalent, String name, String symbol) {
super(baseUnit, baseUnitEquivalent, name, symbol);
}
MassUnit(
MassUnit baseUnit,
UnaryFunction toBaseConverter,
UnaryFunction fromBaseConverter,
String name,
String symbol) {
super(baseUnit, toBaseConverter, fromBaseConverter, name, symbol);
}
@Override
public MassUnit getBaseUnit() {
return (MassUnit) super.getBaseUnit();
}
@Override
public Mass of(double magnitude) {
return new Mass(magnitude, toBaseUnits(magnitude), this);
}
@Override
public Mass ofBaseUnits(double baseUnitMagnitude) {
return new Mass(fromBaseUnits(baseUnitMagnitude), baseUnitMagnitude, this);
}
@Override
public Mass zero() {
return (Mass) super.zero();
}
@Override
public Mass one() {
return (Mass) super.one();
}
@Override
public VelocityUnit