Package org.djunits.quantity.def
Class AbsQuantity<A extends AbsQuantity<A,Q,R>,Q extends Quantity<Q>,R extends Reference<R,A,Q>>
java.lang.Object
org.djunits.quantity.def.AbsBasic<A,Q,R>
org.djunits.quantity.def.AbsQuantity<A,Q,R>
- Type Parameters:
A- the absolute quantity typeQ- the relative quantity typeR- the reference type to use for the absolute quantity
- All Implemented Interfaces:
Serializable,Comparable<A>,Value<A,Q>
- Direct Known Subclasses:
Position,Temperature,Time
public abstract class AbsQuantity<A extends AbsQuantity<A,Q,R>,Q extends Quantity<Q>,R extends Reference<R,A,Q>>
extends AbsBasic<A,Q,R>
implements Comparable<A>
AbsQuantity is an abstract class that stores the basic information about a absolute quantity. An absolute quantity wraps a
relative Quantity and has a reference point that acts as an origin or zero point.
Copyright (c) 2025-2026 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://djunits.org. The DJUNITS project is distributed under a three-clause BSD-style license.
- Author:
- Alexander Verbraeck
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionAbsQuantity(Q quantity, R reference) Instantiate an absolute quantity with a quantity and a reference. -
Method Summary
Modifier and TypeMethodDescriptionfinal intbooleanTest if this Quantity is equal to another Quantity.booleaneq0()Test if this Quantity is equal to 0.0.booleanTest if this Quantity is greater than or equal to another Quantity.booleange0()Test if this Quantity is greater than or equal to 0.0.booleanTest if this Quantity is greater than another Quantity.booleangt0()Test if this Quantity is greater than 0.0.static <A extends AbsQuantity<A,Q, R>, Q extends Quantity<Q>, R extends Reference<R, A, Q>>
Ainterpolate(A zero, A one, double ratio) Interpolate between two absolute quantities.booleanTest if this Quantity is less than or equal to another Quantity.booleanle0()Test if this Quantity is less than or equal to 0.0.booleanTest if this Quantity is less than another Quantity.booleanlt0()Test if this Quantity is less than 0.0.static <A extends AbsQuantity<A,Q, R>, Q extends Quantity<Q>, R extends Reference<R, A, Q>>
Amax(A quantity1, A... quantities) Return the maximum value of one or more quantities.static <A extends AbsQuantity<A,Q, R>, Q extends Quantity<Q>, R extends Reference<R, A, Q>>
Amean(A quantity1, A... quantities) Return the mean of one or more quantities.static <A extends AbsQuantity<A,Q, R>, Q extends Quantity<Q>, R extends Reference<R, A, Q>>
Amin(A quantity1, A... quantities) Return the minimum value of one or more quantities.booleanTest if this Quantity is not equal to another Quantity.booleanne0()Test if this Quantity is not equal to 0.0.static <A extends AbsQuantity<A,Q, R>, Q extends Quantity<Q>, R extends Reference<R, A, Q>>
AReturns an absolute quantity based on a value and the textual representation of the unit, which can be localized.static <A extends AbsQuantity<A,Q, R>, Q extends Quantity<Q>, R extends Reference<R, A, Q>>
AReturns an absolute quantity for the textual representation of a value with a unit.Methods inherited from class org.djunits.quantity.def.AbsBasic
add, equals, format, format, format, getDisplayUnit, getInUnit, getInUnit, getName, getQuantity, getReference, hashCode, instantiate, isRelative, of, relativeTo, setDisplayUnit, si, siUnit, subtract, subtract, toString, valueOfMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.djunits.value.Value
isAbsolute, setDisplayUnit
-
Constructor Details
-
AbsQuantity
Instantiate an absolute quantity with a quantity and a reference.- Parameters:
quantity- the relative quantity that indicates the 'distance' to the reference pointreference- the reference point
-
-
Method Details
-
lt
Test if this Quantity is less than another Quantity.- Parameters:
other- the right hand side operand of the comparison- Returns:
- true if this is less than o; false otherwise
- Throws:
IllegalArgumentException- when the two absolute quantities have a different reference point
-
le
Test if this Quantity is less than or equal to another Quantity.- Parameters:
other- the right hand side operand of the comparison- Returns:
- true if this is less than or equal to o; false otherwise
- Throws:
IllegalArgumentException- when the two absolute quantities have a different reference point
-
gt
Test if this Quantity is greater than another Quantity.- Parameters:
other- the right hand side operand of the comparison- Returns:
- true if this is greater than o; false otherwise
- Throws:
IllegalArgumentException- when the two absolute quantities have a different reference point
-
ge
Test if this Quantity is greater than or equal to another Quantity.- Parameters:
other- the right hand side operand of the comparison- Returns:
- true if this is greater than or equal to o; false otherwise
- Throws:
IllegalArgumentException- when the two absolute quantities have a different reference point
-
eq
Test if this Quantity is equal to another Quantity.- Parameters:
other- the right hand side operand of the comparison- Returns:
- true if this is equal to o; false otherwise
- Throws:
IllegalArgumentException- when the two absolute quantities have a different reference point
-
ne
Test if this Quantity is not equal to another Quantity.- Parameters:
other- the right hand side operand of the comparison- Returns:
- true if this is not equal to o; false otherwise
- Throws:
IllegalArgumentException- when the two absolute quantities have a different reference point
-
lt0
public boolean lt0()Test if this Quantity is less than 0.0.- Returns:
- true if this is less than 0.0; false if this is not less than 0.0
-
le0
public boolean le0()Test if this Quantity is less than or equal to 0.0.- Returns:
- true if this is less than or equal to 0.0; false if this is not less than or equal to 0.0
-
gt0
public boolean gt0()Test if this Quantity is greater than 0.0.- Returns:
- true if this is greater than 0.0; false if this is not greater than 0.0
-
ge0
public boolean ge0()Test if this Quantity is greater than or equal to 0.0.- Returns:
- true if this is greater than or equal to 0.0; false if this is not greater than or equal to 0.0
-
eq0
public boolean eq0()Test if this Quantity is equal to 0.0.- Returns:
- true if this is equal to 0.0; false if this is not equal to 0.0
-
ne0
public boolean ne0()Test if this Quantity is not equal to 0.0.- Returns:
- true if this is not equal to 0.0; false if this is equal to 0.0
-
compareTo
- Specified by:
compareToin interfaceComparable<A extends AbsQuantity<A,Q, R>> - Throws:
IllegalArgumentException- when the two absolute quantities have a different reference point
-
valueOf
public static <A extends AbsQuantity<A,Q, A valueOfR>, Q extends Quantity<Q>, R extends Reference<R, A, Q>> (String text, A example, R reference) Returns an absolute quantity for the textual representation of a value with a unit. The String representation that can be parsed is the double value in the unit, followed by a localized or English abbreviation of the unit. Spaces are allowed, but not required, between the value and the unit.- Type Parameters:
A- the absolute quantity typeQ- the relative quantity typeR- the reference type to use for the absolute quantity- Parameters:
text- the textual representation to parse into the quantityexample- an example instance to deliverreference- the reference point- Returns:
- the absolute quantity representation of the value with its unit
- Throws:
IllegalArgumentException- when the text cannot be parsedNullPointerException- when the text argument is null
-
of
public static <A extends AbsQuantity<A,Q, A ofR>, Q extends Quantity<Q>, R extends Reference<R, A, Q>> (double valueInUnit, String unitString, A example, R reference) Returns an absolute quantity based on a value and the textual representation of the unit, which can be localized.- Type Parameters:
A- the absolute quantity typeQ- the relative quantity typeR- the reference type to use for the absolute quantity- Parameters:
valueInUnit- the value, expressed in the unit as given by unitStringunitString- the textual representation of the unitexample- an absolute example instance to deliverreference- the reference point- Returns:
- the absolute quantity representation of the value in its unit
- Throws:
IllegalArgumentException- when the unit cannot be parsed or is incorrectNullPointerException- when the unitString argument is null
-
interpolate
public static <A extends AbsQuantity<A,Q, A interpolateR>, Q extends Quantity<Q>, R extends Reference<R, A, Q>> (A zero, A one, double ratio) Interpolate between two absolute quantities. Note that the first quantities does not have to be smaller than the second.- Type Parameters:
A- the absolute quantity typeQ- the relative quantity typeR- the reference type to use for the absolute quantity- Parameters:
zero- the quantity at a ratio of zeroone- the quantity at a ratio of oneratio- the ratio between 0 and 1, inclusive- Returns:
- a Quantity at the given ratio between 0 and 1
- Throws:
IllegalArgumentException- when absolute quantities have a different reference point
-
max
@SafeVarargs public static <A extends AbsQuantity<A,Q, A maxR>, Q extends Quantity<Q>, R extends Reference<R, A, Q>> (A quantity1, A... quantities) Return the maximum value of one or more quantities.- Type Parameters:
A- the absolute quantity typeQ- the relative quantity typeR- the reference type to use for the absolute quantity- Parameters:
quantity1- the first quantityquantities- the other quantities- Returns:
- the maximum value of more than two quantities
- Throws:
IllegalArgumentException- when absolute quantities have a different reference point
-
min
@SafeVarargs public static <A extends AbsQuantity<A,Q, A minR>, Q extends Quantity<Q>, R extends Reference<R, A, Q>> (A quantity1, A... quantities) Return the minimum value of one or more quantities.- Type Parameters:
A- the absolute quantity typeQ- the relative quantity typeR- the reference type to use for the absolute quantity- Parameters:
quantity1- the first quantityquantities- the other quantities- Returns:
- the minimum value of more than two quantities
- Throws:
IllegalArgumentException- when absolute quantities have a different reference point
-
mean
@SafeVarargs public static <A extends AbsQuantity<A,Q, A meanR>, Q extends Quantity<Q>, R extends Reference<R, A, Q>> (A quantity1, A... quantities) Return the mean of one or more quantities.- Type Parameters:
A- the absolute quantity typeQ- the relative quantity typeR- the reference type to use for the absolute quantity- Parameters:
quantity1- the first quantityquantities- the other quantities- Returns:
- the mean of the quantities
- Throws:
IllegalArgumentException- when absolute quantities have a different reference point
-