RobotCore 1.0
WPILib port to raspberry Pi
Loading...
Searching...
No Matches
org.wpilib.units.MultUnit< A extends Unit, B extends Unit > Class Template Reference
Inheritance diagram for org.wpilib.units.MultUnit< A extends Unit, B extends Unit >:
org.wpilib.units.Unit

Public Member Functions

Measure<? extends MultUnit< A, B > > of (double magnitude)
Measure<? extends MultUnit< A, B > > ofBaseUnits (double baseUnitMagnitude)
final Mult< A, B > ofNative (double magnitude)
final Mult< A, B > ofNativeBaseUnits (double baseUnitMagnitude)
Measure<? extends MultUnit< A, B > > zero ()
Measure<? extends MultUnit< A, B > > one ()
Unit per (TimeUnit time)
double convertFrom (double magnitude, MultUnit< A, B > otherUnit)
MultUnit< A, B > getBaseUnit ()
A unitA ()
B unitB ()
String toString ()
boolean equals (Object o)
int hashCode ()
Public Member Functions inherited from org.wpilib.units.Unit
boolean isBaseUnit ()
double fromBaseUnits (double valueInBaseUnits)
double toBaseUnits (double valueInNativeUnits)
UnaryFunction getConverterToBase ()
UnaryFunction getConverterFromBase ()
boolean equivalent (Unit other)
String name ()
String symbol ()

Static Public Member Functions

static< A extends Unit, B extends Unit > MultUnit< A, B > combine (A a, B b)

Protected Member Functions

 MultUnit (MultUnit< A, B > baseUnit, A a, B b)
Protected Member Functions inherited from org.wpilib.units.Unit
 Unit (Unit baseUnit, UnaryFunction toBaseConverter, UnaryFunction fromBaseConverter, String name, String symbol)
 Unit (Unit baseUnit, double baseUnitEquivalent, String name, String symbol)

Detailed Description

A combinatory unit type that is equivalent to the product of two other others. Note that algebraic reduction is not possible in Java's generic type system, so MultUnit<A, B> is not type-compatible with MultUnit<B, A>!

Parameters
<A>the type of the first unit in the result
<B>the type of the second unit in the result

Definition at line 18 of file MultUnit.java.

Constructor & Destructor Documentation

◆ MultUnit()

org.wpilib.units.MultUnit< A extends Unit, B extends Unit >.MultUnit ( MultUnit< A, B > baseUnit,
A a,
B b )
protected

Creates a new product unit. Subclasses of MultUnit should use this constructor.

Parameters
baseUnitthe base unit. Set this to null if the unit being constructed is its own base unit
athe first unit of the product
bthe second unit of the product

Definition at line 51 of file MultUnit.java.

Member Function Documentation

◆ combine()

static< A extends Unit, B extends Unit > MultUnit< A, B > org.wpilib.units.MultUnit< A extends Unit, B extends Unit >.combine ( A a,
B b )
static

Creates a new MultUnit unit derived from two arbitrary units multiplied together.

  MultUnit.combine(Volts, Meters) // Volt-Meters
Parameters
<A>the type of the first unit
<B>the type of the second unit
athe first unit
bthe second unit
Returns
the combined unit

Definition at line 86 of file MultUnit.java.

◆ convertFrom()

double org.wpilib.units.MultUnit< A extends Unit, B extends Unit >.convertFrom ( double magnitude,
MultUnit< A, B > otherUnit )

Converts a measurement value in terms of another unit to this unit.

Parameters
magnitudethe magnitude of the measurement in terms of the other unit
otherUnitthe other unit
Returns
the value of the measurement in terms of this unit

Definition at line 170 of file MultUnit.java.

◆ equals()

boolean org.wpilib.units.MultUnit< A extends Unit, B extends Unit >.equals ( Object o)

Reimplemented from org.wpilib.units.Unit.

Definition at line 204 of file MultUnit.java.

◆ getBaseUnit()

MultUnit< A, B > org.wpilib.units.MultUnit< A extends Unit, B extends Unit >.getBaseUnit ( )

Gets the base unit of measurement that this unit is derived from. If the unit is the base unit, the unit will be returned.

NOTE: Subclasses must override this method to provide the correct return type. Failing to do say will make unit combinations that use it break at runtime!


  Unit baseUnit = new Unit(null, ...);
  baseUnit.getBaseUnit(); // returns baseUnit

  Unit derivedUnit = new Unit(baseUnit, ...);
  derivedUnit.getBaseUnit(); // returns baseUnit
Returns
the base unit

Reimplemented from org.wpilib.units.Unit.

Definition at line 176 of file MultUnit.java.

◆ hashCode()

int org.wpilib.units.MultUnit< A extends Unit, B extends Unit >.hashCode ( )

Reimplemented from org.wpilib.units.Unit.

Definition at line 219 of file MultUnit.java.

◆ of()

Measure<? extends MultUnit< A, B > > org.wpilib.units.MultUnit< A extends Unit, B extends Unit >.of ( double magnitude)

Creates a new immutable measurement of the given magnitude in terms of this unit. Implementations are strongly recommended to sharpen the return type to a unit-specific measurement implementation.

Parameters
magnitudethe magnitude of the measurement.
Returns
the measurement object

Note: When called on an object of type MultUnit (and not a subclass!), this method will always return a org.wpilib.units.measure.Mult instance. If you want to avoid casting, use ofNativeBaseUnits(double) that returns a Per instance directly.

Parameters
magnitudethe magnitude of the measure in terms of its base units.
Returns
the measurement object

Reimplemented from org.wpilib.units.Unit.

Definition at line 102 of file MultUnit.java.

◆ ofBaseUnits()

Measure<? extends MultUnit< A, B > > org.wpilib.units.MultUnit< A extends Unit, B extends Unit >.ofBaseUnits ( double baseUnitMagnitude)

Creates a new immutable measurement of the given magnitude in terms of this unit's base unit. Implementations are strongly recommended to sharpen the return type to a unit-specific measurement implementation.

Parameters
baseUnitMagnitudethe magnitude in terms of the base unit
Returns
the measurement object

Note: When called on an object of type MultUnit (and not a subclass!), this method will always return a org.wpilib.units.measure.Mult instance. If you want to avoid casting, use ofNativeBaseUnits(double) that returns a Per instance directly.

Parameters
baseUnitMagnitudethe magnitude of the measure in terms of its base units.
Returns
the measurement object

Reimplemented from org.wpilib.units.Unit.

Definition at line 118 of file MultUnit.java.

◆ ofNative()

final Mult< A, B > org.wpilib.units.MultUnit< A extends Unit, B extends Unit >.ofNative ( double magnitude)

Creates a new immutable measurement of the given magnitude in terms of this unit. This will always return a Mult object and cannot be overridden by subclasses.

Parameters
magnitudethe magnitude of the measurement.
Returns
the measurement object
See also
of(double)

Definition at line 130 of file MultUnit.java.

◆ ofNativeBaseUnits()

final Mult< A, B > org.wpilib.units.MultUnit< A extends Unit, B extends Unit >.ofNativeBaseUnits ( double baseUnitMagnitude)

Creates a new immutable measurement of the given magnitude in terms of the unit's base unit. This will always return a Mult object and cannot be overridden by subclasses.

Parameters
baseUnitMagnitudethe magnitude of the measure in terms of its base units.
Returns
the measurement object
See also
ofBaseUnits(double)

Definition at line 142 of file MultUnit.java.

◆ one()

Measure<? extends MultUnit< A, B > > org.wpilib.units.MultUnit< A extends Unit, B extends Unit >.one ( )

Gets a measure with a magnitude of 1.0 in terms of this unit. The returned object is guaranteed to be of the same type returned by of(double). Subclasses are encouraged to override this method to sharpen the return type.

Returns
a measure of magnitude 1.0 in terms of this unit

Reimplemented from org.wpilib.units.Unit.

Definition at line 154 of file MultUnit.java.

◆ per()

Unit org.wpilib.units.MultUnit< A extends Unit, B extends Unit >.per ( TimeUnit time)

Combines this unit with a unit of time. This often - but not always - results in a velocity. Subclasses should sharpen the return type to be unit-specific.

Parameters
timethe unit of time
Returns
the combined unit

Reimplemented from org.wpilib.units.Unit.

Definition at line 159 of file MultUnit.java.

◆ toString()

String org.wpilib.units.MultUnit< A extends Unit, B extends Unit >.toString ( )

Reimplemented from org.wpilib.units.Unit.

Definition at line 199 of file MultUnit.java.

◆ unitA()

A org.wpilib.units.MultUnit< A extends Unit, B extends Unit >.unitA ( )

Gets the first unit of the product.

Returns
the first unit

Definition at line 185 of file MultUnit.java.

◆ unitB()

B org.wpilib.units.MultUnit< A extends Unit, B extends Unit >.unitB ( )

Gets the second unit of the product.

Returns
the second unit

Definition at line 194 of file MultUnit.java.

◆ zero()

Measure<? extends MultUnit< A, B > > org.wpilib.units.MultUnit< A extends Unit, B extends Unit >.zero ( )

Gets a measure of zero magnitude in terms of this unit. The returned object is guaranteed to be of the same type returned by of(double). Subclasses are encouraged to override this method to sharpen the return type.

Returns
a zero-magnitude measure of this unit

Reimplemented from org.wpilib.units.Unit.

Definition at line 148 of file MultUnit.java.


The documentation for this class was generated from the following file: