Class Quantities

  • All Implemented Interfaces:
    Serializable

    public final class Quantities
    extends Object
    implements Serializable
    UnitTypes is a singleton where the BaseUnit SIDimensions 'fingerprints' are stored and mapped to the BaseUnits. It is possible that more baseUnits have the same fingerprint. E.g., Energy and Torque.

    Copyright (c) 2019-2023 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:
    Serialized Form
    • Field Detail

      • INSTANCE

        public static final Quantities INSTANCE
        The one instance.
    • Method Detail

      • register

        public void register​(Quantity<?> quantity)
        Register the baseUnit in the UnitType registries.
        Parameters:
        quantity - Quantity<?>; the quantity to register.
      • unregister

        public void unregister​(Quantity<?> baseUnit)
        Unregister the baseUnit in the UnitType registries.
        Parameters:
        baseUnit - Quantity<?>; the quantity to register.
      • getQuantities

        public Set<Quantity<?>> getQuantities​(SIDimensions siDimensions)
        Retrieve a safe copy of the quantity set registered for an SI fingerprint.
        Parameters:
        siDimensions - SIDimensions; the SI dimensions to search for
        Returns:
        a safe copy of the baseUnit set registered for this SI dimensions fingerprint
      • getQuantity

        public Quantity<?> getQuantity​(String unitClassName)
        Return the Quantity for a given name of a unit class, or null if it has not been registered.
        Parameters:
        unitClassName - String; the unit class name to search for, e.g., "LengthUnit"
        Returns:
        Quantity; the quantity belonging to the class, or null if not found
      • getRegistry

        public Map<String,​Quantity<?>> getRegistry()
        Returns:
        a defensive copy of the registry