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

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

  • Constructor Details

  • Method Details

    • of

      public static MonthDay of(Month month, Day day)
      DayMonth factory.
      Parameters:
      month - Month 1-12
      day - Day 1-31
      Returns:
      DayMonth object
    • of

      public static MonthDay of(String value)
      DayMonth factory.
      Parameters:
      value - ISO8601 format [m]m-[d]d
      Returns:
      DayMonth object
    • monthValue

      public Month monthValue()
      Returns the month value of this DayMonth.
      Returns:
      The month value represented by this object.
    • dayValue

      public Day dayValue()
      Returns the day value of this DayMonth.
      Returns:
      The day value represented by this object.
    • stringValue

      public String stringValue()
      Returns the String value of this DayMonth in ISO8601 format.
      Specified by:
      stringValue in interface IValueObject
      Returns:
      The String value represented by this object ([m]m-[d]d).
    • 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 DayMonth. The exact details of this representation are unspecified and subject to change, but the following may be regarded as typical: "DayMonth[month=1, day=1]"
      Overrides:
      toString in class Object
      Returns:
      String representation of this DayMonth
      See Also:
    • compareTo

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

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

      public MonthDay subtract(Months months)
      Subtract months from this MonthDay.
      Parameters:
      months - Months to subtract from this MonthDay
      Returns:
      New MonthDay after subtracting months from this MonthDay
      Throws:
      ArithmeticException - In case of an underflow
    • incrementMonth

      public MonthDay incrementMonth()
      Increment this MonthDay by one month.
      Returns:
      New MonthDay after incrementing this MonthDay by one month
      Throws:
      ArithmeticException - In case of an overflow
    • decrementMonth

      public MonthDay decrementMonth()
      Decrement this MonthDay by one month.
      Returns:
      New MonthDay after decrement this MonthDay by one month
      Throws:
      ArithmeticException - In case of an overflow