Interface Value<U extends UnitInterface<U,?>,SELF extends Value<U,SELF>>

Type Parameters:
U - the unit type
SELF - the 'own' type for fluent design
All Superinterfaces:
Serializable
All Known Implementing Classes:
AbsoluteQuantity, AbsorbedDose, Acceleration, AmountOfSubstance, Angle, AngularAcceleration, AngularVelocity, Area, ArealObjectDensity, CatalyticActivity, Density, Dimensionless, Direction, 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, Position, Power, Pressure, Quantity, QuantityTable, RadioActivity, SIQuantity, SolidAngle, Speed, SquareDenseMatrix, SquareMatrix, Temperature, TemperatureDifference, Time, Torque, Vector, Vector1, Vector2, Vector2.Col, Vector2.Row, Vector3, Vector3.Col, Vector3.Row, VectorMatrix, VectorN, VectorN.Col, VectorN.Row, Volume, VolumetricObjectDensity

public interface Value<U extends UnitInterface<U,?>,SELF extends Value<U,SELF>> extends Serializable
Value is the generic interface for all Scalar, Vector and Matrix classes that forces implementation of a few unit- and value-related methods. The Value interface defines a limited number of functions of Math to be implemented for absolute values. Note: a lot of standard Math functions are not implemented, as they don't make sense with the units. E.g., a cubic root of a Volume should give a Length, and not another volume... Trigoniometric functions should not give back the same unit either. The abs() function is not included here, as abs() only makes sense for relative vales. What is the absolute value of 14 January 2016? Therefore the set of functions that the interface forces to implement is rather limited, and certainly not the entire range of java.lang.Math functions.

Copyright (c) 2015-2026 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See DJUNITS License.

Author:
Alexander Verbraeck, Peter Knoppers
  • Method Summary

    Modifier and Type
    Method
    Description
    Retrieve the unit of this Value.
    default boolean
    Indicate whether this is an Absolute Value.
    boolean
    Indicate whether this is a Relative Value.
    default SELF
    setDisplayUnit(String newUnitString)
    Set a new display unit for the value.
    setDisplayUnit(U newUnit)
    Set a new display unit for the value.
    Return a concise description of this value.
    toString(U displayUnit)
    Return a concise description of this value with the values expressed in the specified unit.
  • Method Details

    • getDisplayUnit

      U getDisplayUnit()
      Retrieve the unit of this Value.
      Returns:
      the unit of this Value
    • setDisplayUnit

      SELF setDisplayUnit(U newUnit)
      Set a new display unit for the value. Internally, the value will not changed since it is stored in a base unit.
      Parameters:
      newUnit - the new display unit of this value
      Returns:
      'this' for fluent design
    • setDisplayUnit

      default SELF setDisplayUnit(String newUnitString)
      Set a new display unit for the value. Internally, the value will not changed since it is stored in a base unit.
      Parameters:
      newUnitString - the textual representation of the new display unit of this value
      Returns:
      'this' for fluent design
      Throws:
      UnitRuntimeException - when the unit did not exist, or the abbreviation was not registered
    • isAbsolute

      default boolean isAbsolute()
      Indicate whether this is an Absolute Value.
      Returns:
      whether this is an Absolute Value
    • isRelative

      boolean isRelative()
      Indicate whether this is a Relative Value.
      Returns:
      whether this is a Relative Value
    • toString

      String toString()
      Return a concise description of this value.
      Overrides:
      toString in class Object
      Returns:
      a String with the value contents, without the type, with the unit attached.
    • toString

      String toString(U displayUnit)
      Return a concise description of this value with the values expressed in the specified unit.
      Parameters:
      displayUnit - the unit into which the values are converted for display
      Returns:
      a String with the value contents expressed in the specified unit