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

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

    • seconds

      private final long seconds
      Seconds.
  • Constructor Details

    • Seconds

      private Seconds(long seconds)
      Constructor.
      Parameters:
      seconds - Seconds 0-..
      Throws:
      IndexOutOfBoundsException - When the seconds is less than 0
  • Method Details

    • of

      public static Seconds of(long seconds)
      Seconds factory.
      Parameters:
      seconds - Seconds 0-..
      Returns:
      Seconds object
    • of

      public static Seconds of(String value)
      Seconds factory.
      Parameters:
      value - Seconds 0-.. string
      Returns:
      Seconds object
    • longValue

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

      public String stringValue()
      Returns the value of this Seconds as a String.
      Specified by:
      stringValue in interface IValueObject
      Returns:
      The numeric value represented by this object after conversion to type String.
    • 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 Seconds. The exact details of this representation are unspecified and subject to change, but the following may be regarded as typical: "Seconds[seconds=1]"
      Overrides:
      toString in class Object
      Returns:
      String representation of this Seconds
      See Also:
    • compareTo

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

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

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

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

      public Seconds divide(long divisor)
      Divide seconds 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 Seconds modulo(long divisor)
      Floor modulo seconds by a divisor.
      Parameters:
      divisor - Divisor to divide by
      Returns:
      The floor modulus Seconds - (floorDiv(Seconds, divisor) * divisor)
      Throws:
      ArithmeticException - In case the divisor is 0.