public class QuantityUtil
extends java.lang.Object
Quantitys Equality is understood like represented by Object.equals(Object), so a quantity
of 1km is not equals to 1000m.
Equivalence is based on the quantities magnitude, a quantity of 1km is equivalent to 1000m.
| Modifier and Type | Method and Description |
|---|---|
static <Q extends javax.measure.Quantity<Q>> |
asComparable(javax.measure.Quantity<Q> quantity)
Converts a given quantity to a comparable quantity
|
static <Q extends javax.measure.Quantity<Q>> |
considerablyAbsEqual(javax.measure.Quantity<Q> a,
javax.measure.Quantity<Q> b,
double absQuantityTolerance)
Deprecated.
renamed to
isEquivalentAbs(Quantity, Quantity, double) for
clarity und uniformity |
static boolean |
considerablyEqualAngle(javax.measure.Quantity<javax.measure.quantity.Angle> a,
javax.measure.Quantity<javax.measure.quantity.Angle> b,
double quantityTolerance)
Deprecated.
|
static <Q extends javax.measure.Quantity<Q>> |
considerablyRelEqual(javax.measure.Quantity<Q> a,
javax.measure.Quantity<Q> b,
double relQuantityTolerance)
Deprecated.
Renamed to
isEquivalentRel(Quantity, Quantity, double) for
clarity und uniformity |
static <Q extends javax.measure.Quantity<Q>> |
equals(javax.measure.Quantity<Q> a,
javax.measure.Quantity<Q> b)
Compares two
Quantitys, if they are equal. |
static <Q extends javax.measure.Quantity<Q>> |
equals(javax.measure.Quantity<Q> a,
javax.measure.Quantity<Q> b,
double quantityTolerance)
Compares two
Quantitys, if they are equal. |
static boolean |
isEmpty(javax.measure.Quantity<?> that)
Checks if the given quantity is empty by returning positive if it is an EmptyQuantity.
|
static <Q extends javax.measure.Quantity<Q>> |
isEquivalentAbs(javax.measure.Quantity<Q> a,
javax.measure.Quantity<Q> b)
Compares two
Quantitys, if they are equivalent considering both quantities
magnitude. |
static <Q extends javax.measure.Quantity<Q>> |
isEquivalentAbs(javax.measure.Quantity<Q> a,
javax.measure.Quantity<Q> b,
double absQuantityTolerance)
Compares two
Quantitys, if they are equivalent considering both quantities
magnitude. |
static boolean |
isEquivalentAngle(javax.measure.Quantity<javax.measure.quantity.Angle> a,
javax.measure.Quantity<javax.measure.quantity.Angle> b)
Compares two
Angle Quantitys, if they are equivalent, especially
considering semantic equality for angles. |
static boolean |
isEquivalentAngle(javax.measure.Quantity<javax.measure.quantity.Angle> a,
javax.measure.Quantity<javax.measure.quantity.Angle> b,
double quantityTolerance)
Compares two
Angle Quantitys, if they are equivalent, especially
considering semantic equality for angles. |
static <Q extends javax.measure.Quantity<Q>> |
isEquivalentConsideringEmpty(tech.units.indriya.ComparableQuantity<Q> a,
tech.units.indriya.ComparableQuantity<Q> b)
Compares two
Quantitys, if they are equivalent. |
static <Q extends javax.measure.Quantity<Q>> |
isEquivalentConsideringEmpty(tech.units.indriya.ComparableQuantity<Q> a,
tech.units.indriya.ComparableQuantity<Q> b,
double quantityTolerance)
Compares two
Quantitys, if they are equivalent. |
static <Q extends javax.measure.Quantity<Q>> |
isEquivalentRel(javax.measure.Quantity<Q> a,
javax.measure.Quantity<Q> b)
Compares two
Quantitys, if they are equivalent considering both quantities
magnitude. |
static <Q extends javax.measure.Quantity<Q>> |
isEquivalentRel(javax.measure.Quantity<Q> a,
javax.measure.Quantity<Q> b,
double relQuantityTolerance)
Compares two
Quantitys, if they are equivalent considering both quantities
magnitude. |
static <Q extends javax.measure.Quantity<Q>> |
isTheSameConsideringEmpty(javax.measure.Quantity<Q> a,
javax.measure.Quantity<Q> b)
Deprecated.
Renamed to
equals(Quantity, Quantity) for clarity and
uniformity |
public static <Q extends javax.measure.Quantity<Q>> tech.units.indriya.ComparableQuantity<Q> asComparable(javax.measure.Quantity<Q> quantity)
Q - Type of input quantityquantity - Input quantityComparableQuantitypublic static <Q extends javax.measure.Quantity<Q>> boolean isEquivalentAbs(javax.measure.Quantity<Q> a,
javax.measure.Quantity<Q> b)
Quantitys, if they are equivalent considering both quantities
magnitude. This is foremost important for NumberQuantitys
with internal big decimal or double values. The comparison is made on the absolute difference
of both quantities' value. Both quantities are converted into a's unit before
the comparison. Internally calls isEquivalentAbs(Quantity, Quantity,
double) with a default tolerance of Q - Type of Quantitya - First quantity to compareb - Second quantity to comparepublic static <Q extends javax.measure.Quantity<Q>> boolean isEquivalentAbs(javax.measure.Quantity<Q> a,
javax.measure.Quantity<Q> b,
double absQuantityTolerance)
Quantitys, if they are equivalent considering both quantities
magnitude. This is foremost important for NumberQuantitys
with internal big decimal or double values. The comparison is made on the absolute difference
of both quantities' value. Both quantities are converted into a's unit before
the comparison.Q - Type of Quantitya - First quantity to compareb - Second quantity to compareabsQuantityTolerance - Permissible absolute tolerancea's unit) else false@Deprecated
public static <Q extends javax.measure.Quantity<Q>> boolean considerablyAbsEqual(javax.measure.Quantity<Q> a,
javax.measure.Quantity<Q> b,
double absQuantityTolerance)
isEquivalentAbs(Quantity, Quantity, double) for
clarity und uniformityQuantitys, if they are equivalent considering both quantities
magnitude. This is foremost important for NumberQuantitys
with internal big decimal or double values. The comparison is made on the absolute difference
of both quantities' value. Both quantities are converted into a's unit before
the comparison.Q - Type of Quantitya - First quantity to compareb - Second quantity to compareabsQuantityTolerance - Permissible absolute tolerancea's unit) else falsepublic static <Q extends javax.measure.Quantity<Q>> boolean isEquivalentRel(javax.measure.Quantity<Q> a,
javax.measure.Quantity<Q> b)
Quantitys, if they are equivalent considering both quantities
magnitude. This is foremost important for NumberQuantitys
with internal big decimal or double values. The comparison is made on the relative difference
of both quantities' value with regard to a's value. Both quantities are
converted into a's unit before the comparison. Internally calls isEquivalentRel(Quantity, Quantity, double) with a default tolerance of Q - Type of Quantitya - First quantity to compareb - Second quantity to comparepublic static <Q extends javax.measure.Quantity<Q>> boolean isEquivalentRel(javax.measure.Quantity<Q> a,
javax.measure.Quantity<Q> b,
double relQuantityTolerance)
Quantitys, if they are equivalent considering both quantities
magnitude. This is foremost important for NumberQuantitys
with internal big decimal or double values. The comparison is made on the relative difference
of both quantities' value with regard to a's value. Both quantities are
converted into a's unit before the comparison.Q - Type of Quantitya - First quantity to compareb - Second quantity to comparerelQuantityTolerance - Permissible relative tolerance@Deprecated
public static <Q extends javax.measure.Quantity<Q>> boolean considerablyRelEqual(javax.measure.Quantity<Q> a,
javax.measure.Quantity<Q> b,
double relQuantityTolerance)
isEquivalentRel(Quantity, Quantity, double) for
clarity und uniformityQuantitys, if they are equivalent considering both quantities
magnitude. This is foremost important for NumberQuantitys
with internal big decimal or double values. The comparison is made on the relative difference
of both quantities' value with regard to a's value. Both quantities are
converted into a's unit before the comparison.Q - Type of Quantitya - First quantity to compareb - Second quantity to comparerelQuantityTolerance - Permissible relative tolerancepublic static boolean isEquivalentAngle(javax.measure.Quantity<javax.measure.quantity.Angle> a,
javax.measure.Quantity<javax.measure.quantity.Angle> b)
Angle Quantitys, if they are equivalent, especially
considering semantic equality for angles. This is foremost important for NumberQuantitys with internal big decimal or double values. The
comparison is made on the absolute difference of both quantities' value. As of the repetitive
nature of angles, they have to be treated separately, e.g. -170° is semantically the same angle
as 190°. To ensure this, all quantities are converted to PowerSystemUnits.DEGREE_GEOM.
Internally calls isEquivalentAngle(Quantity, Quantity, double) with a
default tolerance of a - First quantity to compareb - Second quantity to comparepublic static boolean isEquivalentAngle(javax.measure.Quantity<javax.measure.quantity.Angle> a,
javax.measure.Quantity<javax.measure.quantity.Angle> b,
double quantityTolerance)
Angle Quantitys, if they are equivalent, especially
considering semantic equality for angles. This is foremost important for NumberQuantitys with internal big decimal or double values. The
comparison is made on the absolute difference of both quantities' value. As of the repetitive
nature of angles, they have to be treated separately, e.g. -170° is semantically the same angle
as 190°. To ensure this, all quantities are converted to PowerSystemUnits.DEGREE_GEOM.a - First quantity to compareb - Second quantity to comparequantityTolerance - Permissible absolute tolerance@Deprecated
public static boolean considerablyEqualAngle(javax.measure.Quantity<javax.measure.quantity.Angle> a,
javax.measure.Quantity<javax.measure.quantity.Angle> b,
double quantityTolerance)
isEquivalentAngle(Quantity, Quantity, double)Angle Quantitys, if they are equivalent, especially
considering semantic equality for angles. This is foremost important for NumberQuantitys with internal big decimal or double values. The
comparison is made on the absolute difference of both quantities' value. As of the repetitive
nature of angles, they have to be treated separately, e.g. -170° is semantically the same angle
as 190°. To ensure this, all quantities are converted to PowerSystemUnits.DEGREE_GEOM.a - First quantity to compareb - Second quantity to comparequantityTolerance - Permissible absolute tolerancepublic static <Q extends javax.measure.Quantity<Q>> boolean isEquivalentConsideringEmpty(tech.units.indriya.ComparableQuantity<Q> a,
tech.units.indriya.ComparableQuantity<Q> b)
Quantitys, if they are equivalent. Returns true only if both quantities
are of type EmptyQuantity or if they represent equivalent values. Throws a
NullPointerException if any quantity is null, as null is not to be expected as any known empty
value should be replaced by an EmptyQuantity. Internally calls isEquivalentConsideringEmpty(ComparableQuantity, ComparableQuantity, double) with
a default tolerance of
isEquivalentConsideringEmpty(1 km, 1000 m)// true
isEquivalentConsideringEmpty(1.0 km, 1 km) // true
Q - Type of the Quantitya - First quantity to compareb - Second quantity to comparejava.lang.NullPointerException - if any quantity is nullpublic static <Q extends javax.measure.Quantity<Q>> boolean isEquivalentConsideringEmpty(tech.units.indriya.ComparableQuantity<Q> a,
tech.units.indriya.ComparableQuantity<Q> b,
double quantityTolerance)
Quantitys, if they are equivalent. Returns true only if both quantities
are of type EmptyQuantity or if they represent equivalent values, considering the given
tolerance. Throws a NullPointerException if any quantity is null, as null is not to be expected
as any known empty value should be replaced by an EmptyQuantity.
QuantityUtil.isEquivalentConsideringEmpty(1 km, 1000 m, 0) //true
QuantityUtil.isEquivalentConsideringEmpty(1.0 km, 1 km, 0) //true
QuantityUtil.isEquivalentConsideringEmpty(1.0km, 1.1km, 0.1) //true
QuantityUtil.isEquivalentConsideringEmpty(1.0km, 1100m, 0.1) //true
QuantityUtil.isEquivalentConsideringEmpty(1100m, 1.0km, 0.1) //false
Q - Type of the Quantitya - First quantity to compareb - Second quantity to comparequantityTolerance - permissible absolute tolerance - applied in a's unitsjava.lang.NullPointerException - if any quantity is nullpublic static boolean isEmpty(javax.measure.Quantity<?> that)
that - quantity to comparepublic static <Q extends javax.measure.Quantity<Q>> boolean equals(javax.measure.Quantity<Q> a,
javax.measure.Quantity<Q> b)
Quantitys, if they are equal. Returns true only if both quantities are of
type EmptyQuantity or if they are equal in value and Unit. The type of the value
does not matter. Throws a NullPointerException if any quantity is null, as null is not to be
expected as any known empty value should be replaced by an EmptyQuantity.equals(Quantity, Quantity, double) with a default
tolerance of
QuantityUtil.equals(1 km, 1000 m) // false
QuantityUtil.equals(1.0 km, 1 km) //true
Q - Type of the Quantitya - First quantity to compareb - Second quantity to comparejava.lang.NullPointerException - if any quantity is nullpublic static <Q extends javax.measure.Quantity<Q>> boolean equals(javax.measure.Quantity<Q> a,
javax.measure.Quantity<Q> b,
double quantityTolerance)
Quantitys, if they are equal. Returns true only if both quantities are of
type EmptyQuantity or if they are equal in value and Unit. The type of the value
does not matter. Throws a NullPointerException if any quantity is null, as null is not to be
expected as any known empty value should be replaced by an EmptyQuantity.
QuantityUtil.equals(1 km, 1000 m, 0) //false
QuantityUtil.equals(1.0 km, 1 km, 0) //true
QuantityUtil.equals(1.0km, 1.1km, 0.1) //true
Q - Type of the Quantitya - First quantity to compareb - Second quantity to comparequantityTolerance - permissible absolute tolerancejava.lang.NullPointerException - if any quantity is null@Deprecated
public static <Q extends javax.measure.Quantity<Q>> boolean isTheSameConsideringEmpty(javax.measure.Quantity<Q> a,
javax.measure.Quantity<Q> b)
equals(Quantity, Quantity) for clarity and
uniformityQuantitys, if they are equal. Returns true only if both quantities are of
type EmptyQuantity or if they are equal in value and Unit. The type of the value
does not matter. Throws a NullPointerException if any quantity is null, as null is not to be
expected as any known empty value should be replaced by an EmptyQuantity.
isTheSameConsideringEmpty(1 km, 1000 m) // false
isTheSameConsideringEmpty(1.0 km, 1 km) //true
Q - Type of the Quantitya - First quantity to compareb - Second quantity to comparejava.lang.NullPointerException - if any quantity is null