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

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

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

    Constructors
    Modifier
    Constructor
    Description
    private
    Hours(long hours)
    Constructor.
  • Method Summary

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

    Methods inherited from class java.lang.Object

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

    • hours

      private final long hours
      Hours.
  • Constructor Details

    • Hours

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

    • of

      public static Hours of(long hours)
      Hours factory.
      Parameters:
      hours - Hours 0-..
      Returns:
      Hours object
    • of

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

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

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

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

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

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

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