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

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

    Fields
    Modifier and Type
    Field
    Description
    private final long
    Days.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Days(long days)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    add(Days other)
    Add other days to this days.
    int
    Compare with another object.
    divide(long divisor)
    Divide days by a divisor.
    boolean
    Is equal with another object.
    int
    Calculate hash code.
    long
    Returns the value of this Days as a long.
    modulo(long divisor)
    Floor modulo days by a divisor.
    multiply(long multiplier)
    Multiply days with a multiplier.
    static Days
    of(long days)
    Days factory.
    static Days
    of(String value)
    Days factory.
    Returns the value of this Days as a String.
    subtract(Days other)
    Subtract other days from this days.
    Returns the string representation of this Days.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • days

      private final long days
      Days.
  • Constructor Details

    • Days

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

    • of

      public static Days of(long days)
      Days factory.
      Parameters:
      days - Days 0-..
      Returns:
      Days object
    • of

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

      public long longValue()
      Returns the value of this Days 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 Days 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 Days. The exact details of this representation are unspecified and subject to change, but the following may be regarded as typical: "Days[days=1]"
      Overrides:
      toString in class Object
      Returns:
      String representation of this Days
      See Also:
    • compareTo

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

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

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

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

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