Record Class NaftahPeriod.PeriodDefinition

java.lang.Object
java.lang.Record
org.daiitech.naftah.builtin.time.NaftahPeriod.PeriodDefinition
Record Components:
years - the number of years
yearText - the Arabic word for years (default is * Constants.YEAR)
months - the number of months
monthText - the Arabic word for months (default is * Constants.MONTH)
days - the number of days
dayText - the Arabic word for days (default is Constants.DAY)
Enclosing class:
NaftahPeriod

public static record NaftahPeriod.PeriodDefinition(int years, String yearText, int months, String monthText, int days, String dayText) extends Record
Definition of a period in Arabic text, including years, months, and days.
  • Field Details

    • years

      private final int years
      The field for the years record component.
    • yearText

      private final String yearText
      The field for the yearText record component.
    • months

      private final int months
      The field for the months record component.
    • monthText

      private final String monthText
      The field for the monthText record component.
    • days

      private final int days
      The field for the days record component.
    • dayText

      private final String dayText
      The field for the dayText record component.
  • Constructor Details

    • PeriodDefinition

      public PeriodDefinition(int years, String yearText, int months, String monthText, int days, String dayText)
      Creates an instance of a PeriodDefinition record class.
      Parameters:
      years - the value for the years record component
      yearText - the value for the yearText record component
      months - the value for the months record component
      monthText - the value for the monthText record component
      days - the value for the days record component
      dayText - the value for the dayText record component
  • Method Details

    • of

      public static NaftahPeriod.PeriodDefinition of(int years, String yearText, int months, String monthText, int days, String dayText)
      Creates a new NaftahPeriod.PeriodDefinition instance.

      Any missing Arabic text labels are automatically filled using the default Arabic date unit terms defined in Constants.

      Parameters:
      years - the number of years
      yearText - the Arabic text used for the year unit; if null, Constants.YEAR is used
      months - the number of months
      monthText - the Arabic text used for the month unit; if null, Constants.MONTH is used
      days - the number of days
      dayText - the Arabic text used for the day unit; if null, Constants.DAY is used
      Returns:
      a new NaftahPeriod.PeriodDefinition instance
    • of

      public static NaftahPeriod.PeriodDefinition of(int years, int months, int days)
      Creates a new NaftahPeriod.PeriodDefinition instance using the default Arabic date unit labels.
      Parameters:
      years - the number of years
      months - the number of months
      days - the number of days
      Returns:
      a new NaftahPeriod.PeriodDefinition instance
    • toString

      public String toString()
      Returns a formatted Arabic string representing the period.

      Only non-zero units are printed, with the Arabic conjunction " و " between them. If all units are zero, the output defaults to "0 يوم".

      Specified by:
      toString in class Record
      Returns:
      a string describing the period in Arabic
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • years

      public int years()
      Returns the value of the years record component.
      Returns:
      the value of the years record component
    • yearText

      public String yearText()
      Returns the value of the yearText record component.
      Returns:
      the value of the yearText record component
    • months

      public int months()
      Returns the value of the months record component.
      Returns:
      the value of the months record component
    • monthText

      public String monthText()
      Returns the value of the monthText record component.
      Returns:
      the value of the monthText record component
    • days

      public int days()
      Returns the value of the days record component.
      Returns:
      the value of the days record component
    • dayText

      public String dayText()
      Returns the value of the dayText record component.
      Returns:
      the value of the dayText record component