Class StandardUnit<Q extends Quantity<Q>>

java.lang.Object
org.episteme.core.measure.StandardUnit<Q>
All Implemented Interfaces:
Unit<Q>
Direct Known Subclasses:
Currency

public class StandardUnit<Q extends Quantity<Q>> extends Object implements Unit<Q>
Since:
1.0
Author:
Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
  • Constructor Details

    • StandardUnit

      public StandardUnit(String symbol, String name, Dimension dimension)
      Creates a base unit (defines the dimension).
  • Method Details

    • getSymbol

      public String getSymbol()
      Description copied from interface: Unit
      Returns the symbol for this unit (e.g., "m", "kg", "s").

      Symbols follow UCUM (Unified Code for Units of Measure) conventions where possible.

      Specified by:
      getSymbol in interface Unit<Q extends Quantity<Q>>
      Returns:
      the unit symbol
    • getName

      public String getName()
      Description copied from interface: Unit
      Returns the human-readable name for this unit (e.g., "meter", "kilogram").
      Specified by:
      getName in interface Unit<Q extends Quantity<Q>>
      Returns:
      the unit name
    • getDimension

      public Dimension getDimension()
      Description copied from interface: Unit
      Returns the dimension of this unit.

      The dimension describes the physical nature of the quantity (e.g., length, mass, time) as a combination of base SI dimensions.

      Specified by:
      getDimension in interface Unit<Q extends Quantity<Q>>
      Returns:
      the dimension
    • getConverterTo

      public UnitConverter getConverterTo(Unit<Q> targetUnit)
      Description copied from interface: Unit
      Returns a converter to convert values from this unit to the target unit.

      Both units must have compatible dimensions.

      Specified by:
      getConverterTo in interface Unit<Q extends Quantity<Q>>
      Parameters:
      targetUnit - the target unit
      Returns:
      a converter from this unit to the target
    • multiply

      public Unit<Q> multiply(double factor)
      Description copied from interface: Unit
      Returns a unit equal to this unit multiplied by the specified factor.

      For example, METER.multiply(1000) gives kilometer.

      Specified by:
      multiply in interface Unit<Q extends Quantity<Q>>
      Parameters:
      factor - the multiplier
      Returns:
      the scaled unit
    • divide

      public Unit<Q> divide(double divisor)
      Description copied from interface: Unit
      Returns a unit equal to this unit divided by the specified factor.

      For example, METER.divide(100) gives centimeter.

      Specified by:
      divide in interface Unit<Q extends Quantity<Q>>
      Parameters:
      divisor - the divisor
      Returns:
      the scaled unit
    • multiply

      public Unit<?> multiply(Unit<?> other)
      Description copied from interface: Unit
      Returns the product of this unit with another unit.

      For example, multiplying Length by Length gives Area.

      Specified by:
      multiply in interface Unit<Q extends Quantity<Q>>
      Parameters:
      other - the unit to multiply with
      Returns:
      the product unit
    • divide

      public Unit<?> divide(Unit<?> other)
      Description copied from interface: Unit
      Returns the quotient of this unit by another unit.

      For example, dividing Length by Time gives Velocity.

      Specified by:
      divide in interface Unit<Q extends Quantity<Q>>
      Parameters:
      other - the unit to divide by
      Returns:
      the quotient unit
    • add

      public Unit<Q> add(double offset)
      Returns a unit equal to this unit shifted by the specified offset.

      For example, KELVIN.add(273.15) gives Celsius.

      Parameters:
      offset - the offset to add
      Returns:
      the shifted unit
    • pow

      public Unit<?> pow(int exponent)
      Description copied from interface: Unit
      Returns this unit raised to the specified power.

      For example, METER.pow(2) gives square meters (area).

      Specified by:
      pow in interface Unit<Q extends Quantity<Q>>
      Parameters:
      exponent - the exponent
      Returns:
      the unit raised to the power
    • sqrt

      public Unit<?> sqrt()
      Description copied from interface: Unit
      Returns the square root of this unit.

      The dimension exponents must all be even.

      Specified by:
      sqrt in interface Unit<Q extends Quantity<Q>>
      Returns:
      the square root unit
    • isBaseUnit

      public boolean isBaseUnit()
      Description copied from interface: Unit
      Checks if this is a base SI unit (meter, kilogram, second, etc.).
      Specified by:
      isBaseUnit in interface Unit<Q extends Quantity<Q>>
      Returns:
      true if this is a base unit
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object