Class Milliseconds

java.lang.Object
de.powerstat.validation.values.Milliseconds
All Implemented Interfaces:
IValueObject, Comparable<Milliseconds>

public final class Milliseconds extends Object implements Comparable<Milliseconds>, IValueObject
Milliseconds. Not DSGVO relevant. TODO min, max
  • Field Details

    • milliseconds

      private final long milliseconds
      Milliseonds.
  • Constructor Details

    • Milliseconds

      private Milliseconds(long milliseconds)
      Constructor.
      Parameters:
      milliseconds - Milliseconds >= 0
      Throws:
      IndexOutOfBoundsException - When the milliseonds is less than 0
  • Method Details

    • of

      public static Milliseconds of(long milliseconds)
      Milliseconds factory.
      Parameters:
      milliseconds - Milliseconds 0-[Long.MAX_VALUE]
      Returns:
      Milliseconds object
    • of

      public static Milliseconds of(String value)
      Milliseconds factory.
      Parameters:
      value - Milliseconds 0-[Long.MAX_VALUE] string
      Returns:
      Milliseconds object
    • longValue

      public long longValue()
      Returns the value of this Milliseconds as a long.
      Returns:
      The numeric value represented by this object after conversion to type long (0-Long.MAX_VALUE).
    • stringValue

      public String stringValue()
      Returns the value of this Milliseconds as a String.
      Specified by:
      stringValue in interface IValueObject
      Returns:
      The numeric value represented by this object after conversion to type String (0-Long.MAX_VALUE).
    • hashCode

      public int hashCode()
      Calculate hash code.
      Overrides:
      hashCode in class Object
      Returns:
      Hash
      See Also:
    • equals

      public boolean equals(Object obj)
      Is equal with another object.
      Overrides:
      equals in class Object
      Parameters:
      obj - Object
      Returns:
      true when equal, false otherwise
      See Also:
    • toString

      public String toString()
      Returns the string representation of this Milliseconds. The exact details of this representation are unspecified and subject to change, but the following may be regarded as typical: "Milliseconds[milliseconds=0]"
      Overrides:
      toString in class Object
      Returns:
      String representation of this Milliseconds
      See Also:
    • compareTo

      public int compareTo(Milliseconds obj)
      Compare with another object.
      Specified by:
      compareTo in interface Comparable<Milliseconds>
      Parameters:
      obj - Object to compare with
      Returns:
      0: equal; 1: greater; -1: smaller
      See Also:
    • add

      public Milliseconds add(Milliseconds other)
      Add other milliseconds to this milliseconds.
      Parameters:
      other - Other milliseconds to add to this milliseconds
      Returns:
      New milliseconds after adding other milliseconds to this milliseconds
      Throws:
      ArithmeticException - In case of an overflow
    • subtract

      public Milliseconds subtract(Milliseconds other)
      Subtract other milliseconds from this milliseconds.
      Parameters:
      other - Other milliseconds to subtract from this one
      Returns:
      Absolute new milliseconds after subtracting other milliseconds from this Milliseconds
    • multiply

      public Milliseconds multiply(long multiplier)
      Multiply milliseconds with a multiplier.
      Parameters:
      multiplier - Multiplier to multiply with
      Returns:
      New milliseconds that is a multiplication of this milliseconds with the multiplier
      Throws:
      ArithmeticException - In case of an overflow
    • divide

      public Milliseconds divide(long divisor)
      Divide milliseconds by a divisor.
      Parameters:
      divisor - Divisor to divide by
      Returns:
      The largest (closest to positive infinity) long value that is less than or equal to the algebraic quotient.
      Throws:
      ArithmeticException - In case the divisor is 0.
    • modulo

      public Milliseconds modulo(long divisor)
      Floor modulo milliseconds by a divisor.
      Parameters:
      divisor - Divisor to divide by
      Returns:
      The floor modulus Milliseconds - (floorDiv(Milliseconds, divisor) * divisor)
      Throws:
      ArithmeticException - In case the divisor is 0.