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

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

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

    Constructors
    Modifier
    Constructor
    Description
    private
    Weeks(long weeks)
    Constructor.
  • Method Summary

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

    Methods inherited from class java.lang.Object

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

    • weeks

      private final long weeks
      Weeks.
  • Constructor Details

    • Weeks

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

    • of

      public static Weeks of(long weeks)
      Weeks factory.
      Parameters:
      weeks - Weeks 0-..
      Returns:
      Weeks object
    • of

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

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

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

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

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

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

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

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