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

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

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

    Constructors
    Modifier
    Constructor
    Description
    private
    Years(long years)
    Constructor.
  • Method Summary

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

    Methods inherited from class java.lang.Object

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

    • years

      private final long years
      Years.
  • Constructor Details

    • Years

      private Years(long years)
      Constructor.
      Parameters:
      years - Years >= 0
      Throws:
      IndexOutOfBoundsException - When the year is smaller than 0
  • Method Details

    • of

      public static Years of(long years)
      Years factory.
      Parameters:
      years - Years >= 0
      Returns:
      Years object
    • of

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

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

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

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

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

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

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