Package org.daiitech.naftah.builtin.time
Record Class NaftahPeriod.PeriodDefinition
java.lang.Object
java.lang.Record
org.daiitech.naftah.builtin.time.NaftahPeriod.PeriodDefinition
- Record Components:
years- the number of yearsyearText- the Arabic word for years (default is *Constants.YEAR)months- the number of monthsmonthText- the Arabic word for months (default is *Constants.MONTH)days- the number of daysdayText- the Arabic word for days (default isConstants.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 Summary
FieldsModifier and TypeFieldDescriptionprivate final intThe field for thedaysrecord component.private final StringThe field for thedayTextrecord component.private final intThe field for themonthsrecord component.private final StringThe field for themonthTextrecord component.private final intThe field for theyearsrecord component.private final StringThe field for theyearTextrecord component. -
Constructor Summary
ConstructorsConstructorDescriptionPeriodDefinition(int years, String yearText, int months, String monthText, int days, String dayText) Creates an instance of aPeriodDefinitionrecord class. -
Method Summary
Modifier and TypeMethodDescriptionintdays()Returns the value of thedaysrecord component.dayText()Returns the value of thedayTextrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.intmonths()Returns the value of themonthsrecord component.Returns the value of themonthTextrecord component.of(int years, int months, int days) Creates a newNaftahPeriod.PeriodDefinitioninstance using the default Arabic date unit labels.Creates a newNaftahPeriod.PeriodDefinitioninstance.toString()Returns a formatted Arabic string representing the period.intyears()Returns the value of theyearsrecord component.yearText()Returns the value of theyearTextrecord component.
-
Field Details
-
years
private final int yearsThe field for theyearsrecord component. -
yearText
The field for theyearTextrecord component. -
months
private final int monthsThe field for themonthsrecord component. -
monthText
The field for themonthTextrecord component. -
days
private final int daysThe field for thedaysrecord component. -
dayText
The field for thedayTextrecord component.
-
-
Constructor Details
-
PeriodDefinition
public PeriodDefinition(int years, String yearText, int months, String monthText, int days, String dayText) Creates an instance of aPeriodDefinitionrecord class.- Parameters:
years- the value for theyearsrecord componentyearText- the value for theyearTextrecord componentmonths- the value for themonthsrecord componentmonthText- the value for themonthTextrecord componentdays- the value for thedaysrecord componentdayText- the value for thedayTextrecord component
-
-
Method Details
-
of
public static NaftahPeriod.PeriodDefinition of(int years, String yearText, int months, String monthText, int days, String dayText) Creates a newNaftahPeriod.PeriodDefinitioninstance.Any missing Arabic text labels are automatically filled using the default Arabic date unit terms defined in
Constants.- Parameters:
years- the number of yearsyearText- the Arabic text used for the year unit; ifnull,Constants.YEARis usedmonths- the number of monthsmonthText- the Arabic text used for the month unit; ifnull,Constants.MONTHis useddays- the number of daysdayText- the Arabic text used for the day unit; ifnull,Constants.DAYis used- Returns:
- a new
NaftahPeriod.PeriodDefinitioninstance
-
of
Creates a newNaftahPeriod.PeriodDefinitioninstance using the default Arabic date unit labels.- Parameters:
years- the number of yearsmonths- the number of monthsdays- the number of days- Returns:
- a new
NaftahPeriod.PeriodDefinitioninstance
-
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 يوم".
-
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
years
public int years()Returns the value of theyearsrecord component.- Returns:
- the value of the
yearsrecord component
-
yearText
Returns the value of theyearTextrecord component.- Returns:
- the value of the
yearTextrecord component
-
months
public int months()Returns the value of themonthsrecord component.- Returns:
- the value of the
monthsrecord component
-
monthText
Returns the value of themonthTextrecord component.- Returns:
- the value of the
monthTextrecord component
-
days
public int days()Returns the value of thedaysrecord component.- Returns:
- the value of the
daysrecord component
-
dayText
Returns the value of thedayTextrecord component.- Returns:
- the value of the
dayTextrecord component
-