Interface Value<U extends Unit<U>,T extends Value<U,T>>

Type Parameters:
U - the unit type
T - the value type for this unit
All Superinterfaces:
Cloneable, Serializable
All Known Implementing Classes:
AbsoluteTemperature, AbsoluteTemperatureMatrix, AbsoluteTemperatureVector, AbsorbedDose, AbsorbedDoseMatrix, AbsorbedDoseVector, Acceleration, AccelerationMatrix, AccelerationVector, AmountOfSubstance, AmountOfSubstanceMatrix, AmountOfSubstanceVector, Angle, AngleMatrix, AngleVector, AngularAcceleration, AngularAccelerationMatrix, AngularAccelerationVector, AngularVelocity, AngularVelocityMatrix, AngularVelocityVector, Area, AreaMatrix, AreaVector, CatalyticActivity, CatalyticActivityMatrix, CatalyticActivityVector, Density, DensityMatrix, DensityVector, Dimensionless, DimensionlessMatrix, DimensionlessVector, Direction, DirectionMatrix, DirectionVector, DoubleMatrix, DoubleMatrixAbs, DoubleMatrixRel, DoubleMatrixRelWithAbs, DoubleScalar, DoubleScalarAbs, DoubleScalarRel, DoubleScalarRelWithAbs, DoubleVector, DoubleVectorAbs, DoubleVectorRel, DoubleVectorRelWithAbs, Duration, DurationMatrix, DurationVector, ElectricalCapacitance, ElectricalCapacitanceMatrix, ElectricalCapacitanceVector, ElectricalCharge, ElectricalChargeMatrix, ElectricalChargeVector, ElectricalConductance, ElectricalConductanceMatrix, ElectricalConductanceVector, ElectricalCurrent, ElectricalCurrentMatrix, ElectricalCurrentVector, ElectricalInductance, ElectricalInductanceMatrix, ElectricalInductanceVector, ElectricalPotential, ElectricalPotentialMatrix, ElectricalPotentialVector, ElectricalResistance, ElectricalResistanceMatrix, ElectricalResistanceVector, Energy, EnergyMatrix, EnergyVector, EquivalentDose, EquivalentDoseMatrix, EquivalentDoseVector, FloatAbsoluteTemperature, FloatAbsoluteTemperatureMatrix, FloatAbsoluteTemperatureVector, FloatAbsorbedDose, FloatAbsorbedDoseMatrix, FloatAbsorbedDoseVector, FloatAcceleration, FloatAccelerationMatrix, FloatAccelerationVector, FloatAmountOfSubstance, FloatAmountOfSubstanceMatrix, FloatAmountOfSubstanceVector, FloatAngle, FloatAngleMatrix, FloatAngleVector, FloatAngularAcceleration, FloatAngularAccelerationMatrix, FloatAngularAccelerationVector, FloatAngularVelocity, FloatAngularVelocityMatrix, FloatAngularVelocityVector, FloatArea, FloatAreaMatrix, FloatAreaVector, FloatCatalyticActivity, FloatCatalyticActivityMatrix, FloatCatalyticActivityVector, FloatDensity, FloatDensityMatrix, FloatDensityVector, FloatDimensionless, FloatDimensionlessMatrix, FloatDimensionlessVector, FloatDirection, FloatDirectionMatrix, FloatDirectionVector, FloatDuration, FloatDurationMatrix, FloatDurationVector, FloatElectricalCapacitance, FloatElectricalCapacitanceMatrix, FloatElectricalCapacitanceVector, FloatElectricalCharge, FloatElectricalChargeMatrix, FloatElectricalChargeVector, FloatElectricalConductance, FloatElectricalConductanceMatrix, FloatElectricalConductanceVector, FloatElectricalCurrent, FloatElectricalCurrentMatrix, FloatElectricalCurrentVector, FloatElectricalInductance, FloatElectricalInductanceMatrix, FloatElectricalInductanceVector, FloatElectricalPotential, FloatElectricalPotentialMatrix, FloatElectricalPotentialVector, FloatElectricalResistance, FloatElectricalResistanceMatrix, FloatElectricalResistanceVector, FloatEnergy, FloatEnergyMatrix, FloatEnergyVector, FloatEquivalentDose, FloatEquivalentDoseMatrix, FloatEquivalentDoseVector, FloatFlowMass, FloatFlowMassMatrix, FloatFlowMassVector, FloatFlowVolume, FloatFlowVolumeMatrix, FloatFlowVolumeVector, FloatForce, FloatForceMatrix, FloatForceVector, FloatFrequency, FloatFrequencyMatrix, FloatFrequencyVector, FloatIlluminance, FloatIlluminanceMatrix, FloatIlluminanceVector, FloatLength, FloatLengthMatrix, FloatLengthVector, FloatLinearDensity, FloatLinearDensityMatrix, FloatLinearDensityVector, FloatLuminousFlux, FloatLuminousFluxMatrix, FloatLuminousFluxVector, FloatLuminousIntensity, FloatLuminousIntensityMatrix, FloatLuminousIntensityVector, FloatMagneticFlux, FloatMagneticFluxDensity, FloatMagneticFluxDensityMatrix, FloatMagneticFluxDensityVector, FloatMagneticFluxMatrix, FloatMagneticFluxVector, FloatMass, FloatMassMatrix, FloatMassVector, FloatMatrix, FloatMatrixAbs, FloatMatrixRel, FloatMatrixRelWithAbs, FloatMomentum, FloatMomentumMatrix, FloatMomentumVector, FloatPosition, FloatPositionMatrix, FloatPositionVector, FloatPower, FloatPowerMatrix, FloatPowerVector, FloatPressure, FloatPressureMatrix, FloatPressureVector, FloatRadioActivity, FloatRadioActivityMatrix, FloatRadioActivityVector, FloatScalar, FloatScalarAbs, FloatScalarRel, FloatScalarRelWithAbs, FloatSIMatrix, FloatSIScalar, FloatSIVector, FloatSolidAngle, FloatSolidAngleMatrix, FloatSolidAngleVector, FloatSpeed, FloatSpeedMatrix, FloatSpeedVector, FloatTemperature, FloatTemperatureMatrix, FloatTemperatureVector, FloatTime, FloatTimeMatrix, FloatTimeVector, FloatTorque, FloatTorqueMatrix, FloatTorqueVector, FloatVector, FloatVectorAbs, FloatVectorRel, FloatVectorRelWithAbs, FloatVolume, FloatVolumeMatrix, FloatVolumeVector, FlowMass, FlowMassMatrix, FlowMassVector, FlowVolume, FlowVolumeMatrix, FlowVolumeVector, Force, ForceMatrix, ForceVector, Frequency, FrequencyMatrix, FrequencyVector, Illuminance, IlluminanceMatrix, IlluminanceVector, IndexedValue, Length, LengthMatrix, LengthVector, LinearDensity, LinearDensityMatrix, LinearDensityVector, LuminousFlux, LuminousFluxMatrix, LuminousFluxVector, LuminousIntensity, LuminousIntensityMatrix, LuminousIntensityVector, MagneticFlux, MagneticFluxDensity, MagneticFluxDensityMatrix, MagneticFluxDensityVector, MagneticFluxMatrix, MagneticFluxVector, Mass, MassMatrix, MassVector, Matrix, Momentum, MomentumMatrix, MomentumVector, Position, PositionMatrix, PositionVector, Power, PowerMatrix, PowerVector, Pressure, PressureMatrix, PressureVector, RadioActivity, RadioActivityMatrix, RadioActivityVector, Scalar, SIMatrix, SIScalar, SIVector, SolidAngle, SolidAngleMatrix, SolidAngleVector, Speed, SpeedMatrix, SpeedVector, Temperature, TemperatureMatrix, TemperatureVector, Time, TimeMatrix, TimeVector, Torque, TorqueMatrix, TorqueVector, Vector, Volume, VolumeMatrix, VolumeVector

public interface Value<U extends Unit<U>,T extends Value<U,T>> extends Serializable, Cloneable
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-2024 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
    abs()
    Return a new Scalar/Vector/Matrix with absolute value(s).
    Return a new Scalar/Vector/Matrix with the nearest integer value(s) above the current value(s).
    Return a new Scalar/Vector/Matrix with the nearest integer value(s) below the current value(s).
    Retrieve the unit of this Value.
    default boolean
    Indicate whether this is an Absolute Value.
    default boolean
    Indicate whether this is a Relative Value.
    neg()
    Return a new Scalar/Vector/Matrix with negated value(s).
    Return a new Scalar/Vector/Matrix with the nearest integer value(s).
    void
    setDisplayUnit(U newUnit)
    Set a new display unit for the value.
    Concise description of this value.
    toString(boolean verbose, boolean withUnit)
    Somewhat verbose description of this value with optional type and unit information.
    toString(U displayUnit)
    Somewhat verbose description of this value with the values expressed in the specified unit.
    toString(U displayUnit, boolean verbose, boolean withUnit)
    Somewhat verbose description of this value with the values expressed in the specified unit.
  • Method Details

    • getDisplayUnit

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

      void setDisplayUnit(U newUnit)
      Set a new display unit for the value. Internally, the value will stay stored in the default or SI unit.
      Parameters:
      newUnit - U; the new display unit of this Value
    • isAbsolute

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

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

      String toString()
      Concise description of this value.
      Overrides:
      toString in class Object
      Returns:
      a String with the value, non-verbose, with the unit attached.
    • toString

      String toString(U displayUnit)
      Somewhat verbose description of this value with the values expressed in the specified unit.
      Parameters:
      displayUnit - U; the unit into which the values are converted for display
      Returns:
      String; printable string with the value contents expressed in the specified unit
    • toString

      String toString(boolean verbose, boolean withUnit)
      Somewhat verbose description of this value with optional type and unit information.
      Parameters:
      verbose - boolean; if true; include type info; if false; exclude type info
      withUnit - boolean; if true; include the unit; of false; exclude the unit
      Returns:
      String; printable string with the value contents
    • toString

      String toString(U displayUnit, boolean verbose, boolean withUnit)
      Somewhat verbose description of this value with the values expressed in the specified unit.
      Parameters:
      displayUnit - U; the unit into which the values are converted for display
      verbose - boolean; if true; include type info; if false; exclude type info
      withUnit - boolean; if true; include the unit; of false; exclude the unit
      Returns:
      String; printable string with the value contents
    • abs

      T abs()
      Return a new Scalar/Vector/Matrix with absolute value(s).
      Returns:
      R; a new R with absolute value(s)
    • ceil

      T ceil()
      Return a new Scalar/Vector/Matrix with the nearest integer value(s) above the current value(s).
      Returns:
      R; a new R with absolute value(s)
    • floor

      T floor()
      Return a new Scalar/Vector/Matrix with the nearest integer value(s) below the current value(s).
      Returns:
      R; a new R with absolute value(s)
    • neg

      T neg()
      Return a new Scalar/Vector/Matrix with negated value(s).
      Returns:
      R; a new R with negated value(s)
    • rint

      T rint()
      Return a new Scalar/Vector/Matrix with the nearest integer value(s). When the value is exactly in the middle between two integer values, the even one is returned.
      Returns:
      R; a new R with absolute value(s)