Class Scalar<U extends Unit<U>,S extends Scalar<U,S>>

java.lang.Object
java.lang.Number
org.djunits.value.base.Scalar<U,S>
Type Parameters:
U - the unit
S - the scalar type with the given unit
All Implemented Interfaces:
Serializable, Cloneable, Comparable<S>, Value<U,S>
Direct Known Subclasses:
DoubleScalar, FloatScalar

public abstract class Scalar<U extends Unit<U>,S extends Scalar<U,S>> extends Number implements Value<U,S>, Comparable<S>
Scalar to distinguish a scalar from vectors and matrices.

Copyright (c) 2019-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
See Also:
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Scalar(U displayUnit)
    Construct a new Scalar.
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract boolean
    eq(S o)
    Test if this DoubleScalar is equal to another DoubleScalar.
    abstract boolean
    eq0()
    Test if this DoubleScalar is equal to 0.0.
    format(double d)
    Format a string according to the current locale and the standard (minimized) format, such as "3.14" or "300.0".
    format(double d, String format)
    Format a string according to the current locale and the provided format string.
    abstract boolean
    ge(S o)
    Test if this DoubleScalar is greater than or equal to another DoubleScalar.
    abstract boolean
    ge0()
    Test if this DoubleScalar is greater than or equal to 0.0.
    final U
    Retrieve the unit of this Value.
    abstract boolean
    gt(S o)
    Test if this DoubleScalar is greater than another DoubleScalar.
    abstract boolean
    gt0()
    Test if this DoubleScalar is greater than 0.0.
    abstract boolean
    le(S o)
    Test if this DoubleScalar is less than or equal to another DoubleScalar.
    abstract boolean
    le0()
    Test if this DoubleScalar is less than or equal to 0.0.
    abstract boolean
    lt(S o)
    Test if this DoubleScalar is less than another DoubleScalar.
    abstract boolean
    lt0()
    Test if this DoubleScalar is less than 0.0.
    abstract boolean
    ne(S o)
    Test if this DoubleScalar is not equal to another DoubleScalar.
    abstract boolean
    ne0()
    Test if this DoubleScalar is not equal to 0.0.
    void
    setDisplayUnit(U newUnit)
    Set a new display unit for the value.
    abstract String
    Concise display description of this value, without the engineering formatting, so without trailing zeroes.
    abstract String
    toDisplayString(U displayUnit)
    Concise display description of this value, without the engineering formatting, so without trailing zeroes.
    abstract String
    Concise textual representation of this value, without the engineering formatting, so without trailing zeroes.
    abstract String
    toTextualString(U displayUnit)
    Concise textual representation of this value, without the engineering formatting, so without trailing zeroes.

    Methods inherited from class java.lang.Number

    byteValue, doubleValue, floatValue, intValue, longValue, shortValue

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.lang.Comparable

    compareTo

    Methods inherited from interface org.djunits.value.Value

    abs, ceil, floor, isAbsolute, isRelative, neg, rint, toString, toString, toString, toString
  • Constructor Details

    • Scalar

      protected Scalar(U displayUnit)
      Construct a new Scalar.
      Parameters:
      displayUnit - U; the unit of the new AbstractScalar
  • Method Details

    • getDisplayUnit

      public final U getDisplayUnit()
      Retrieve the unit of this Value.
      Specified by:
      getDisplayUnit in interface Value<U extends Unit<U>,S extends Scalar<U,S>>
      Returns:
      U; the unit of this Value
    • setDisplayUnit

      public void setDisplayUnit(U newUnit)
      Set a new display unit for the value. Internally, the value will stay stored in the default or SI unit.
      Specified by:
      setDisplayUnit in interface Value<U extends Unit<U>,S extends Scalar<U,S>>
      Parameters:
      newUnit - U; the new display unit of this Value
    • lt

      public abstract boolean lt(S o)
      Test if this DoubleScalar is less than another DoubleScalar.
      Parameters:
      o - T, a relative typed DoubleScalar; the right hand side operand of the comparison
      Returns:
      boolean; true if this is less than o; false otherwise
    • le

      public abstract boolean le(S o)
      Test if this DoubleScalar is less than or equal to another DoubleScalar.
      Parameters:
      o - T, a relative typed DoubleScalar; the right hand side operand of the comparison
      Returns:
      boolean; true if this is less than or equal to o; false otherwise
    • gt

      public abstract boolean gt(S o)
      Test if this DoubleScalar is greater than another DoubleScalar.
      Parameters:
      o - T, a relative typed DoubleScalar; the right hand side operand of the comparison
      Returns:
      boolean; true if this is greater than o; false otherwise
    • ge

      public abstract boolean ge(S o)
      Test if this DoubleScalar is greater than or equal to another DoubleScalar.
      Parameters:
      o - T, a relative typed DoubleScalar; the right hand side operand of the comparison
      Returns:
      boolean; true if this is greater than or equal to o; false otherwise
    • eq

      public abstract boolean eq(S o)
      Test if this DoubleScalar is equal to another DoubleScalar.
      Parameters:
      o - T, a relative typed DoubleScalar; the right hand side operand of the comparison
      Returns:
      boolean; true if this is equal to o; false otherwise
    • ne

      public abstract boolean ne(S o)
      Test if this DoubleScalar is not equal to another DoubleScalar.
      Parameters:
      o - T, a relative typed DoubleScalar; the right hand side operand of the comparison
      Returns:
      boolean; true if this is not equal to o; false otherwise
    • lt0

      public abstract boolean lt0()
      Test if this DoubleScalar is less than 0.0.
      Returns:
      boolean; true if this is less than 0.0; false if this is not less than 0.0
    • le0

      public abstract boolean le0()
      Test if this DoubleScalar is less than or equal to 0.0.
      Returns:
      boolean; 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 abstract boolean gt0()
      Test if this DoubleScalar is greater than 0.0.
      Returns:
      boolean; true if this is greater than 0.0; false if this is not greater than 0.0
    • ge0

      public abstract boolean ge0()
      Test if this DoubleScalar is greater than or equal to 0.0.
      Returns:
      boolean; 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 abstract boolean eq0()
      Test if this DoubleScalar is equal to 0.0.
      Returns:
      boolean; true if this is equal to 0.0; false if this is not equal to 0.0
    • ne0

      public abstract boolean ne0()
      Test if this DoubleScalar is not equal to 0.0.
      Returns:
      boolean; true if this is not equal to 0.0; false if this is equal to 0.0
    • toTextualString

      public abstract String toTextualString()
      Concise textual representation of this value, without the engineering formatting, so without trailing zeroes. A space is added between the number and the unit.
      Returns:
      a String with the value with the default textual representation of the unit attached.
    • toTextualString

      public abstract String toTextualString(U displayUnit)
      Concise textual representation of this value, without the engineering formatting, so without trailing zeroes. A space is added between the number and the unit.
      Parameters:
      displayUnit - U; the display unit for the value
      Returns:
      a String with the value with the default textual representation of the provided unit attached.
    • toDisplayString

      public abstract String toDisplayString()
      Concise display description of this value, without the engineering formatting, so without trailing zeroes. A space is added between the number and the unit.
      Returns:
      a String with the value with the default display representation of the unit attached.
    • toDisplayString

      public abstract String toDisplayString(U displayUnit)
      Concise display description of this value, without the engineering formatting, so without trailing zeroes. A space is added between the number and the unit.
      Parameters:
      displayUnit - U; the display unit for the value
      Returns:
      a String with the value with the default display representation of the provided unit attached.
    • format

      public String format(double d)
      Format a string according to the current locale and the standard (minimized) format, such as "3.14" or "300.0".
      Parameters:
      d - double; the number to format
      Returns:
      String; the formatted number using the current Locale
    • format

      public String format(double d, String format)
      Format a string according to the current locale and the provided format string.
      Parameters:
      d - double; the number to format
      format - String; the formatting string to use for the number
      Returns:
      String; the formatted number using the current Locale and the format string