Class ComparableAbsQuantity<A extends ComparableAbsQuantity<A,Q,R>,Q extends Quantity<Q>,R extends Reference<R,A,Q>>

java.lang.Object
org.djunits.quantity.def.AbsQuantity<A,Q,R>
org.djunits.quantity.def.ComparableAbsQuantity<A,Q,R>
Type Parameters:
A - the absolute quantity type
Q - the relative quantity type
R - the reference type to use for the absolute quantity
All Implemented Interfaces:
Serializable, Comparable<A>, Value<Q>
Direct Known Subclasses:
Position, Temperature, Time

public abstract class ComparableAbsQuantity<A extends ComparableAbsQuantity<A,Q,R>,Q extends Quantity<Q>,R extends Reference<R,A,Q>> extends AbsQuantity<A,Q,R> implements Comparable<A>
ComparableAbsQuantity is an abstract class that stores the basic information about an absolute quantity that is comparable. Note that two directions are not comparable based on the SI values, but, e.g., two temperatures are. All absolute quantities wrap a relative Quantity and have 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

    Constructors
    Constructor
    Description
    ComparableAbsQuantity(Q quantity, R reference)
    Instantiate an absolute quantity with a quantity and a reference.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    compareTo(A other)
    boolean
    eq(A other)
    Test if this absolute quantity is equal to another absolute quantity.
    boolean
    eq0()
    Test if this absolute quantity is equal to 0.0.
    boolean
    ge(A other)
    Test if this absolute quantity is greater than or equal to another absolute quantity.
    boolean
    ge0()
    Test if this absolute quantity is greater than or equal to 0.0.
    boolean
    gt(A other)
    Test if this absolute quantity is greater than another absolute quantity.
    boolean
    gt0()
    Test if this absolute quantity is greater than 0.0.
    static <A extends ComparableAbsQuantity<A, Q, R>, Q extends Quantity<Q>, R extends Reference<R, A, Q>>
    A
    interpolate(A zero, A one, double ratio)
    Interpolate between two absolute quantities.
    boolean
    le(A other)
    Test if this absolute quantity is less than or equal to another absolute quantity.
    boolean
    le0()
    Test if this absolute quantity is less than or equal to 0.0.
    boolean
    lt(A other)
    Test if this absolute quantity is less than another absolute quantity.
    boolean
    lt0()
    Test if this absolute quantity is less than 0.0.
    static <A extends ComparableAbsQuantity<A, Q, R>, Q extends Quantity<Q>, R extends Reference<R, A, Q>>
    A
    max(A quantity1, A... quantities)
    Return the maximum value of one or more quantities.
    static <A extends ComparableAbsQuantity<A, Q, R>, Q extends Quantity<Q>, R extends Reference<R, A, Q>>
    A
    mean(A quantity1, A... quantities)
    Return the mean of one or more quantities.
    static <A extends ComparableAbsQuantity<A, Q, R>, Q extends Quantity<Q>, R extends Reference<R, A, Q>>
    A
    min(A quantity1, A... quantities)
    Return the minimum value of one or more quantities.
    boolean
    ne(A other)
    Test if this absolute quantity is not equal to another absolute quantity.
    boolean
    ne0()
    Test if this absolute quantity is not equal to 0.0.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.djunits.value.Value

    isAbsolute
  • Constructor Details

    • ComparableAbsQuantity

      public ComparableAbsQuantity(Q quantity, R reference)
      Instantiate an absolute quantity with a quantity and a reference.
      Parameters:
      quantity - the relative quantity that indicates the 'distance' to the reference point
      reference - the reference point
  • Method Details

    • lt

      public boolean lt(A other)
      Test if this absolute quantity is less than another absolute quantity.
      Parameters:
      other - the right hand side operand of the comparison
      Returns:
      true if this is less than other; false otherwise
      Throws:
      IllegalArgumentException - when the two absolute quantities have a different reference point
    • le

      public boolean le(A other)
      Test if this absolute quantity is less than or equal to another absolute quantity.
      Parameters:
      other - the right hand side operand of the comparison
      Returns:
      true if this is less than or equal to other; false otherwise
      Throws:
      IllegalArgumentException - when the two absolute quantities have a different reference point
    • gt

      public boolean gt(A other)
      Test if this absolute quantity is greater than another absolute quantity.
      Parameters:
      other - the right hand side operand of the comparison
      Returns:
      true if this is greater than other; false otherwise
      Throws:
      IllegalArgumentException - when the two absolute quantities have a different reference point
    • ge

      public boolean ge(A other)
      Test if this absolute quantity is greater than or equal to another absolute quantity.
      Parameters:
      other - the right hand side operand of the comparison
      Returns:
      true if this is greater than or equal to other; false otherwise
      Throws:
      IllegalArgumentException - when the two absolute quantities have a different reference point
    • eq

      public boolean eq(A other)
      Test if this absolute quantity is equal to another absolute quantity.
      Parameters:
      other - the right hand side operand of the comparison
      Returns:
      true if this is equal to other; false otherwise
      Throws:
      IllegalArgumentException - when the two absolute quantities have a different reference point
    • ne

      public boolean ne(A other)
      Test if this absolute quantity is not equal to another absolute quantity.
      Parameters:
      other - the right hand side operand of the comparison
      Returns:
      true if this is not equal to other; false otherwise
      Throws:
      IllegalArgumentException - when the two absolute quantities have a different reference point
    • lt0

      public boolean lt0()
      Test if this absolute 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 absolute 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 absolute 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 absolute 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 absolute 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 absolute 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

      public int compareTo(A other)
      Specified by:
      compareTo in interface Comparable<A extends ComparableAbsQuantity<A,Q,R>>
      Throws:
      IllegalArgumentException - when the two absolute quantities have a different reference point
    • interpolate

      public static <A extends ComparableAbsQuantity<A, Q, R>, Q extends Quantity<Q>, R extends Reference<R, A, Q>> A interpolate(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 type
      Q - the relative quantity type
      R - the reference type to use for the absolute quantity
      Parameters:
      zero - the quantity at a ratio of zero
      one - the quantity at a ratio of one
      ratio - 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 ComparableAbsQuantity<A, Q, R>, Q extends Quantity<Q>, R extends Reference<R, A, Q>> A max(A quantity1, A... quantities)
      Return the maximum value of one or more quantities.
      Type Parameters:
      A - the absolute quantity type
      Q - the relative quantity type
      R - the reference type to use for the absolute quantity
      Parameters:
      quantity1 - the first quantity
      quantities - 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 ComparableAbsQuantity<A, Q, R>, Q extends Quantity<Q>, R extends Reference<R, A, Q>> A min(A quantity1, A... quantities)
      Return the minimum value of one or more quantities.
      Type Parameters:
      A - the absolute quantity type
      Q - the relative quantity type
      R - the reference type to use for the absolute quantity
      Parameters:
      quantity1 - the first quantity
      quantities - 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 ComparableAbsQuantity<A, Q, R>, Q extends Quantity<Q>, R extends Reference<R, A, Q>> A mean(A quantity1, A... quantities)
      Return the mean of one or more quantities.
      Type Parameters:
      A - the absolute quantity type
      Q - the relative quantity type
      R - the reference type to use for the absolute quantity
      Parameters:
      quantity1 - the first quantity
      quantities - the other quantities
      Returns:
      the mean of the quantities
      Throws:
      IllegalArgumentException - when absolute quantities have a different reference point