Package tech.units.indriya
Interface ComparableQuantity<Q extends Quantity<Q>>
-
- Type Parameters:
Q- the quantity type
- All Superinterfaces:
Comparable<Quantity<Q>>,Quantity<Q>,tech.uom.lib.common.function.QuantityConverter<Q>,Serializable
- All Known Implementing Classes:
AbstractQuantity,NumberQuantity,TemporalQuantity,TimeUnitQuantity
public interface ComparableQuantity<Q extends Quantity<Q>> extends Quantity<Q>, Comparable<Quantity<Q>>, tech.uom.lib.common.function.QuantityConverter<Q>, Serializable
Quantity that adapts Comparable to theQuantityinterface. For use in other quantities, when supposed to work on Comparables. It extends Quantity with Comparable and Serializable- Since:
- 1.0
- Version:
- 2.6, November 14, 2024
- Author:
- otaviojava, werner
- See Also:
Quantity
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface javax.measure.Quantity
Quantity.Scale
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ComparableQuantity<Q>add(Quantity<Q> that)<T extends Quantity<T>>
ComparableQuantity<T>asType(Class<T> type)ComparableQuantity<Q>divide(Number that)ComparableQuantity<?>divide(Quantity<?> that)<T extends Quantity<T>,E extends Quantity<E>>
ComparableQuantity<E>divide(Quantity<T> that, Class<E> asTypeQuantity)Multiply and cast theComparableQuantityComparableQuantity<?>inverse()<T extends Quantity<T>>
ComparableQuantity<T>inverse(Class<T> quantityClass)invert and already cast to defined quantityClassbooleanisGreaterThan(Quantity<Q> that)Compares two instances ofQuantity.booleanisGreaterThanOrEqualTo(Quantity<Q> that)Compares two instances ofQuantity, converting the unit if necessary.booleanisLessThan(Quantity<Q> that)Compares two instances ofQuantity, converting the unit if necessary.booleanisLessThanOrEqualTo(Quantity<Q> that)Compares two instances ofQuantity, converting the unit if necessary.ComparableQuantity<Q>multiply(Number multiplier)ComparableQuantity<?>multiply(Quantity<?> multiplier)<T extends Quantity<T>,E extends Quantity<E>>
ComparableQuantity<E>multiply(Quantity<T> that, Class<E> asTypeQuantity)Divide and cast theComparableQuantityComparableQuantity<Q>subtract(Quantity<Q> that)ComparableQuantity<Q>to(Unit<Q> unit)-
Methods inherited from interface java.lang.Comparable
compareTo
-
Methods inherited from interface javax.measure.Quantity
getScale, getUnit, getValue, isEquivalentTo, negate, toSystemUnit
-
-
-
-
Method Detail
-
add
ComparableQuantity<Q> add(Quantity<Q> that)
-
subtract
ComparableQuantity<Q> subtract(Quantity<Q> that)
-
divide
ComparableQuantity<?> divide(Quantity<?> that)
-
divide
ComparableQuantity<Q> divide(Number that)
-
multiply
ComparableQuantity<?> multiply(Quantity<?> multiplier)
-
multiply
ComparableQuantity<Q> multiply(Number multiplier)
-
inverse
ComparableQuantity<?> inverse()
-
inverse
<T extends Quantity<T>> ComparableQuantity<T> inverse(Class<T> quantityClass)
invert and already cast to defined quantityClass- Parameters:
quantityClass- Quantity to be converted- See Also:
Quantity.inverse(),Quantity.asType(Class)
-
to
ComparableQuantity<Q> to(Unit<Q> unit)
-
asType
<T extends Quantity<T>> ComparableQuantity<T> asType(Class<T> type) throws ClassCastException
- Specified by:
asTypein interfaceQuantity<Q extends Quantity<Q>>- Throws:
ClassCastException- See Also:
Quantity.asType(Class)
-
isGreaterThan
boolean isGreaterThan(Quantity<Q> that)
Compares two instances ofQuantity. Conversion of unit can happen if necessary- Parameters:
that- thequantity<Q>to be compared with this instance.- Returns:
trueifthis > that.- Throws:
NullPointerException- if the that is null
-
isGreaterThanOrEqualTo
boolean isGreaterThanOrEqualTo(Quantity<Q> that)
Compares two instances ofQuantity, converting the unit if necessary.- Parameters:
that- thequantity<Q>to be compared with this instance.- Returns:
trueifthis >= that.- Throws:
NullPointerException- if the that is null
-
isLessThan
boolean isLessThan(Quantity<Q> that)
Compares two instances ofQuantity, converting the unit if necessary.- Parameters:
that- thequantity<Q>to be compared with this instance.- Returns:
trueifthis < that.- Throws:
NullPointerException- if the quantity is null
-
isLessThanOrEqualTo
boolean isLessThanOrEqualTo(Quantity<Q> that)
Compares two instances ofQuantity, converting the unit if necessary.- Parameters:
that- thequantity<Q>to be compared with this instance.- Returns:
trueifthis <= that.- Throws:
NullPointerException- if the quantity is null
-
divide
<T extends Quantity<T>,E extends Quantity<E>> ComparableQuantity<E> divide(Quantity<T> that, Class<E> asTypeQuantity)
Multiply and cast theComparableQuantity- Parameters:
that- quantity to be multipliedasTypeQuantity- quantity to be converted- Returns:
- the QuantityOperations multiplied and converted
- Throws:
NullPointerException- See Also:
Quantity.divide(Quantity),Quantity.asType(Class)
-
multiply
<T extends Quantity<T>,E extends Quantity<E>> ComparableQuantity<E> multiply(Quantity<T> that, Class<E> asTypeQuantity)
Divide and cast theComparableQuantity- Parameters:
that- quantity to be dividedasTypeQuantity- quantity to be converted- Returns:
- the QuantityOperations multiplied and converted
- Throws:
NullPointerException- See Also:
QuantityOperations,QuantityOperations#of(Quantity, Class),Quantity.asType(Class),Quantity.multiply(Quantity)
-
-