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

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

    • months

      private final long months
      Month.
  • Constructor Details

    • Months

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

    • of

      public static Months of(long months)
      Months factory.
      Parameters:
      months - Months 0-..
      Returns:
      Months object
    • of

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

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

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

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

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

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

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