Class Frequency

  • All Implemented Interfaces:
    Comparable<Frequency>, RichComparable<Frequency>

    public final class Frequency
    extends Object
    implements RichComparable<Frequency>
    Class representing frequency. This class is intended to be used for a value whose unit is Hz and its family (KHz, MHz, etc.).

    Note: this class is mainly intended to be used for lambda, which represents THz order. Long has enough space to represent over THz frequency as Hz, and the underlying value is long as Hz. This means this class can't represent sub-Hz accuracy.

    • Method Detail

      • asHz

        public long asHz()
        Return the value this instance represents as Hz.
        Returns:
        frequency in Hz
      • asKHz

        public double asKHz()
        Return the value this instance represents as KHz.
        Returns:
        frequency in kHz
      • asMHz

        public double asMHz()
        Return the value this instance represents as MHz.
        Returns:
        frequency in MHz
      • asGHz

        public double asGHz()
        Return the value this instance represents as GHz.
        Returns:
        frequency in GHz
      • asTHz

        public double asTHz()
        Return the value this instance represents as THz.
        Returns:
        frequency in THz
      • ofHz

        public static Frequency ofHz​(long value)
        Returns an instance representing the specified value in Hz.
        Parameters:
        value - frequency in Hz
        Returns:
        instance representing the given frequency
      • ofKHz

        public static Frequency ofKHz​(long value)
        Returns an instance representing the specified value in KHz.
        Parameters:
        value - frequency in KHz
        Returns:
        instance representing the given frequency
      • ofKHz

        public static Frequency ofKHz​(double value)
        Returns an instance representing the specified value in KHz.
        Parameters:
        value - frequency in KHz
        Returns:
        instance representing the given frequency
      • ofMHz

        public static Frequency ofMHz​(long value)
        Returns an instance representing the specified value in MHz.
        Parameters:
        value - frequency in MHz
        Returns:
        instance representing the given frequency
      • ofMHz

        public static Frequency ofMHz​(double value)
        Returns an instance representing the specified value in MHz.
        Parameters:
        value - frequency in MHz
        Returns:
        instance representing the given frequency
      • ofGHz

        public static Frequency ofGHz​(long value)
        Returns an instance representing the specified value in GHz.
        Parameters:
        value - frequency in GHz
        Returns:
        instance representing the given frequency
      • ofGHz

        public static Frequency ofGHz​(double value)
        Returns an instance representing the specified value in GHz.
        Parameters:
        value - frequency in GHz
        Returns:
        instance representing the given frequency
      • ofTHz

        public static Frequency ofTHz​(long value)
        Returns an instance representing the specified value in THz.
        Parameters:
        value - frequency in THz
        Returns:
        instance representing the given frequency
      • ofTHz

        public static Frequency ofTHz​(double value)
        Returns an instance representing the specified value in THz.
        Parameters:
        value - frequency in THz
        Returns:
        instance representing the given frequency
      • add

        public Frequency add​(Frequency value)
        Returns a Frequency whose value is (this + value).
        Parameters:
        value - value to be added to this Frequency
        Returns:
        this + value
      • subtract

        public Frequency subtract​(Frequency value)
        Returns a Frequency whose value is (this - value).
        Parameters:
        value - value to be subtracted from this Frequency
        Returns:
        this - value
      • multiply

        public Frequency multiply​(long value)
        Returns a Frequency whose value is (this * value).
        Parameters:
        value - value to be multiplied by this Frequency
        Returns:
        this * value
      • floorDivision

        public Frequency floorDivision​(long value)
        Returns a Frequency whose value is Math.floorDiv(this, value).
        Parameters:
        value - value to be divided by this Frequency
        Returns:
        Math.floorDiv(this, value)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object