Record Class NaftahTime.ZoneOrOffset

java.lang.Object
java.lang.Record
org.daiitech.naftah.builtin.time.NaftahTime.ZoneOrOffset
Record Components:
arabicZoneOrOffset - the Arabic zone name or offset string
offset - true if the value is a numeric offset, false if a named zone
zoneId - the resolved ZoneId representation
Enclosing class:
NaftahTime

public static record NaftahTime.ZoneOrOffset(String arabicZoneOrOffset, boolean offset, ZoneId zoneId) extends Record
Represents an Arabic time zone or numeric offset.

Stores the original Arabic zone or offset string, a boolean indicating whether it is a numeric offset, and the resolved ZoneId.

  • Field Details

    • arabicZoneOrOffset

      private final String arabicZoneOrOffset
      The field for the arabicZoneOrOffset record component.
    • offset

      private final boolean offset
      The field for the offset record component.
    • zoneId

      private final ZoneId zoneId
      The field for the zoneId record component.
  • Constructor Details

    • ZoneOrOffset

      public ZoneOrOffset(String arabicZoneOrOffset, boolean offset, ZoneId zoneId)
      Creates an instance of a ZoneOrOffset record class.
      Parameters:
      arabicZoneOrOffset - the value for the arabicZoneOrOffset record component
      offset - the value for the offset record component
      zoneId - the value for the zoneId record component
  • Method Details

    • parseZone

      private static ZoneId parseZone(String arabicZoneOrOffset, boolean offset)
    • ofZone

      public static NaftahTime.ZoneOrOffset ofZone(String arabicZone)
      Creates a ZoneOrOffset instance representing a named time zone.
      Parameters:
      arabicZone - the Arabic name of the time zone
      Returns:
      a new ZoneOrOffset instance
    • ofOffset

      public static NaftahTime.ZoneOrOffset ofOffset(String offset)
      Creates a ZoneOrOffset instance representing a numeric offset.
      Parameters:
      offset - the offset string (e.g., "+02:00")
      Returns:
      a new ZoneOrOffset instance
    • toString

      public String toString()
      Returns a string representation of this ZoneOrOffset.
      • If it represents an offset, returns the offset string directly.
      • If it represents a named time zone, returns "بتوقيت <zoneName>"
      • If the zone name is empty, returns an empty string.
      Specified by:
      toString in class Record
      Returns:
      a formatted string representing the zone or offset
    • 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.
    • arabicZoneOrOffset

      public String arabicZoneOrOffset()
      Returns the value of the arabicZoneOrOffset record component.
      Returns:
      the value of the arabicZoneOrOffset record component
    • offset

      public boolean offset()
      Returns the value of the offset record component.
      Returns:
      the value of the offset record component
    • zoneId

      public ZoneId zoneId()
      Returns the value of the zoneId record component.
      Returns:
      the value of the zoneId record component