Enum Class Unit

java.lang.Object
java.lang.Enum<Unit>
com.arpnetworking.metrics.mad.model.Unit
All Implemented Interfaces:
Serializable, Comparable<Unit>, Constable

public enum Unit extends Enum<Unit>
Specifies the unit on a counter variable.
Author:
Brandon Arp (brandon dot arp at inscopemetrics dot io), Ville Koskela (ville dot koskela at inscopemetrics dot io)
  • Enum Constant Details

    • NANOSECOND

      public static final Unit NANOSECOND
      Nanoseconds.
    • MICROSECOND

      public static final Unit MICROSECOND
      Microseconds.
    • MILLISECOND

      public static final Unit MILLISECOND
      Milliseconds.
    • SECOND

      public static final Unit SECOND
      Seconds.
    • MINUTE

      public static final Unit MINUTE
      Minutes.
    • HOUR

      public static final Unit HOUR
      Hours.
    • DAY

      public static final Unit DAY
      Days.
    • WEEK

      public static final Unit WEEK
      Weeks.
    • BIT

      public static final Unit BIT
      Bits.
    • BYTE

      public static final Unit BYTE
      Bytes.
    • KILOBIT

      public static final Unit KILOBIT
      Kilobits.
    • MEGABIT

      public static final Unit MEGABIT
      Megabits.
    • GIGABIT

      public static final Unit GIGABIT
      Gigabits.
    • TERABIT

      public static final Unit TERABIT
      Terabits.
    • PETABIT

      public static final Unit PETABIT
      Petabits.
    • KILOBYTE

      public static final Unit KILOBYTE
      Kilobytes.
    • MEGABYTE

      public static final Unit MEGABYTE
      Megabytes.
    • GIGABYTE

      public static final Unit GIGABYTE
      Gigabytes.
    • TERABYTE

      public static final Unit TERABYTE
      Terabytes.
    • PETABYTE

      public static final Unit PETABYTE
      Petabytes.
    • KELVIN

      public static final Unit KELVIN
      Kelvin.
    • CELCIUS

      public static final Unit CELCIUS
      Celcius.
    • FAHRENHEIT

      public static final Unit FAHRENHEIT
      Fahrenheit.
  • Method Details

    • values

      public static Unit[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static Unit valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getType

      public UnitType getType()
    • convert

      public double convert(double sourceValue, Unit sourceUnit)
      Converts a value in one unit to another.
      Parameters:
      sourceValue - the value to be converted
      sourceUnit - the unit of the source value
      Returns:
      the value after conversion
    • getSmallestUnit

      public Unit getSmallestUnit()
      Gets the smallest unit for this unit's type.
      Returns:
      the smallest unit
    • getSmallerUnit

      public Unit getSmallerUnit(Unit otherUnit)
      Gets the smaller unit of two.
      Parameters:
      otherUnit - the unit to compare this against
      Returns:
      the smaller unit
    • isSmallerThan

      public boolean isSmallerThan(Unit otherUnit)
      Determines if the current unit is smaller than another.
      Parameters:
      otherUnit - The other unit.
      Returns:
      true if the current unit is smaller than otherUnit, otherwise false.
    • getSmallerUnit

      public static Optional<Unit> getSmallerUnit(Optional<Unit> unitA, Optional<Unit> unitB)
      Return the smaller of two Optional units or absent if neither is present. If only one is present this throws an IllegalArgumentException.
      Parameters:
      unitA - Optional unit.
      unitB - Optional unit.
      Returns:
      Optional unit.