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

public final class Hour extends Object implements Comparable<Hour>, IValueObject
Hour. Not DSGVO relevant. TODO Listener TODO minutesWithin = 60 TODO min, max
  • Field Details

  • Constructor Details

    • Hour

      private Hour(int hour)
      Constructor.
      Parameters:
      hour - Hour 0-23
      Throws:
      IndexOutOfBoundsException - When the hour is less than 0 or greater than 23
  • Method Details

    • of

      public static Hour of(int hour)
      Hour factory.
      Parameters:
      hour - Hour 0-23
      Returns:
      Hour object
    • of

      public static Hour of(String value)
      Hour factory.
      Parameters:
      value - Hour 0-23 string
      Returns:
      Hour object
    • intValue

      public int intValue()
      Returns the value of this Hour as an int.
      Returns:
      The numeric value represented by this object after conversion to type int.
    • stringValue

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

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

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

      public Hour subtract(Hours hours)
      Subtract hours from this hour.
      Parameters:
      hours - Hours to subtract from this hour
      Returns:
      New hour after subtracting hours from this hour
      Throws:
      ArithmeticException - In case of an underflow
    • increment

      public Hour increment()
      Increment this hour.
      Returns:
      New hour after incrementing this hour
      Throws:
      ArithmeticException - In case of an overflow
    • decrement

      public Hour decrement()
      Decrement this hour.
      Returns:
      New hour after decrement this hour
      Throws:
      ArithmeticException - In case of an overflow