Interface Additive<T extends Additive<T>>

Type Parameters:
T - the element type
All Known Implementing Classes:
AbsorbedDose, Acceleration, AmountOfSubstance, Angle, AngularAcceleration, AngularVelocity, Area, ArealObjectDensity, CatalyticActivity, Density, Dimensionless, Duration, ElectricalCapacitance, ElectricalConductance, ElectricalInductance, ElectricalResistance, ElectricCharge, ElectricCurrent, ElectricPotential, Energy, EquivalentDose, FlowMass, FlowVolume, Force, Frequency, Illuminance, Length, LinearDensity, LinearObjectDensity, LuminousFlux, LuminousIntensity, MagneticFlux, MagneticFluxDensity, Mass, Matrix, Matrix1x1, Matrix2x2, Matrix3x3, MatrixNxM, MatrixNxN, Momentum, Power, Pressure, Quantity, QuantityTable, RadioActivity, SIQuantity, SolidAngle, Speed, SquareDenseMatrix, SquareMatrix, TemperatureDifference, Torque, Vector, Vector1, Vector2, Vector2.Col, Vector2.Row, Vector3, Vector3.Col, Vector3.Row, VectorMatrix, VectorN, VectorN.Col, VectorN.Row, Volume, VolumetricObjectDensity

public interface Additive<T extends Additive<T>>
Additive indicates that elements of the same type can be added, subtracted and negated, based on the SI-values. Note that not all unit-carrying elements are additive. An example is an absolute scalar (e.g., a date) that cannot be added to another absolute scalar.

Warning: additive operations on units with an Offset Scale might lead to unexpected answers. 10 °C + 5 °C = 288.15 °C and not 15 °C. 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
  • Method Summary

    Modifier and Type
    Method
    Description
    abs()
    Make the SI-values of this element absolute.
    add(T other)
    Add an element to this element, based on the SI-values.
    Negate this element, based on the SI-values.
    subtract(T other)
    Subtract an element from this element, based on the SI-values.
  • Method Details

    • add

      T add(T other)
      Add an element to this element, based on the SI-values. Note that this can lead to unwanted effects for elements with Offset scales: 10 °C + 5 °C = 288.15 °C and not 15 °C.
      Parameters:
      other - the element to add to this element
      Returns:
      the sum of the SI-values of this element and the SI-values of the other element
    • subtract

      T subtract(T other)
      Subtract an element from this element, based on the SI-values.
      Parameters:
      other - the element to subtract from this element
      Returns:
      a new element with the SI-values of this element minus the SI-values of the other element
    • negate

      T negate()
      Negate this element, based on the SI-values. Note that this can lead to unwanted effects for elements with Offset scales. A temperature in Celsius that is negated, will have its Kelvin temperatures negated.
      Returns:
      a new element with all of its SI-values negated
    • abs

      T abs()
      Make the SI-values of this element absolute. A new element wil be returned. Note that this can lead to unwanted effects for elements with Offset scales. A temperature of -10 degrees Celsius will have its Kelvin temperatures negated.
      Returns:
      a new element with the absolute value for all of its SI-values