Package javax.measure
Interface Quantity<Q extends Quantity<Q>>
- Type Parameters:
Q- The type of the quantity.
- All Known Subinterfaces:
Acceleration,AmountOfSubstance,Angle,Area,CatalyticActivity,Dimensionless,ElectricCapacitance,ElectricCharge,ElectricConductance,ElectricCurrent,ElectricInductance,ElectricPotential,ElectricResistance,Energy,Force,Frequency,Illuminance,Length,LuminousFlux,LuminousIntensity,MagneticFlux,MagneticFluxDensity,Mass,Power,Pressure,RadiationDoseAbsorbed,RadiationDoseEffective,Radioactivity,SolidAngle,Speed,Temperature,Time,Volume
public interface Quantity<Q extends Quantity<Q>>
Represents a quantitative property of a phenomenon, body, or substance, that can be quantified by measurement.
Mass, time, distance, heat, and angular separation are among the familiar examples of quantitative properties.
Unit<Mass> pound = ... Quantity<Length> size = ... Sensor<Temperature>
thermometer = ... Vector3D<Speed> aircraftSpeed = ...
- Since:
- 1.0
- Version:
- 1.0, August 8, 2016
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionReturns the sum of thisQuantitywith the one specified.Casts this quantity to a parameterized unit of specified nature or throw aClassCastExceptionif the dimension of the specified quantity and this measure unit's dimension do not match.Returns the product of thisQuantitydivided by theNumberspecified.Quantity<?> Returns the product of thisQuantitydivided by theQuantityspecified.getUnit()Returns the unit of thisQuantity.getValue()Returns the value of thisQuantity.Quantity<?> inverse()Returns aQuantitywhose unit isunit.inverse().Returns the product of thisQuantitywith theNumbervalue specified.Quantity<?> Returns the product of thisQuantitywith the one specified.Returns the difference between thisQuantityand the one specified.Returns thisQuantityconverted into another (compatible)Unit.
-
Method Details
-
add
Returns the sum of thisQuantitywith the one specified.- Parameters:
augend- theQuantityto be added.- Returns:
this + augend.
-
subtract
Returns the difference between thisQuantityand the one specified.- Parameters:
subtrahend- theQuantityto be subtracted.- Returns:
this - that.
-
divide
Returns the product of thisQuantitydivided by theQuantityspecified.- Parameters:
divisor- theQuantitydivisor.- Returns:
this / that.- Throws:
ClassCastException- if the type of an element in the specified operation is incompatible with this quantity (optional)
-
divide
Returns the product of thisQuantitydivided by theNumberspecified.- Parameters:
divisor- theNumberdivisor.- Returns:
this / that.
-
multiply
Returns the product of thisQuantitywith the one specified.- Parameters:
multiplier- theQuantitymultiplier.- Returns:
this * multiplier.- Throws:
ClassCastException- if the type of an element in the specified operation is incompatible with this quantity (optional)
-
multiply
Returns the product of thisQuantitywith theNumbervalue specified.- Parameters:
multiplier- theNumbermultiplier.- Returns:
this * multiplier.
-
inverse
Quantity<?> inverse()Returns aQuantitywhose unit isunit.inverse().- Returns:
Quantity with this.getUnit().inverse().
-
to
Returns thisQuantityconverted into another (compatible)Unit.- Parameters:
unit- theUnitto convert to.- Returns:
- the converted result.
-
asType
Casts this quantity to a parameterized unit of specified nature or throw aClassCastExceptionif the dimension of the specified quantity and this measure unit's dimension do not match. For example:Quantity<Length> length = Quantities.getQuantity("2 km").asType(Length.class);orQuantity<Speed> C = length.multiply(299792458).divide(second).asType(Speed.class);- Type Parameters:
T- The type of the quantity.- Parameters:
type- the quantity class identifying the nature of the quantity.- Returns:
- this quantity parameterized with the specified type.
- Throws:
ClassCastException- if the dimension of this unit is different from the specified quantity dimension.UnsupportedOperationException- if the specified quantity class does not have a SI unit for the quantity.- See Also:
-
getValue
Number getValue()Returns the value of thisQuantity.- Returns:
- a value.
-
getUnit
Returns the unit of thisQuantity.- Returns:
- the unit (shall not be
null).
-