Class ThaiLanguageHandler

java.lang.Object
io.github.zazalng.handler.ThaiLanguageHandler
All Implemented Interfaces:
LanguageHandler

public class ThaiLanguageHandler extends Object implements LanguageHandler
Thai language implementation of LanguageHandler.

This handler converts numeric amounts to Thai textual representation using traditional Thai numerical conventions and grammar rules. It implements the complete conversion logic previously found in ThaiConvertHandler.

Thai Grammar Rules Implemented

This converter implements comprehensive Thai numerical grammar including:

  • "เอ็ด" (edt): Used for the ones digit in compound numbers (e.g., 101 = "หนึ่งร้อยเอ็ด", 21 = "ยี่สิบเอ็ด" but NOT 1 alone)
  • "ยี่" (yee): Special form for twenty (20 = "ยี่สิบ") and for twenties in compound numbers (120 = "หนึ่งร้อยยี่สิบ")
  • Silent "หนึ่ง" (1): In tens position, 10 is "สิบ" not "หนึ่งสิบ"
  • Repeating "ล้าน" (millions): Large numbers repeat the word "ล้าน" for groups of millions (e.g., 1,000,000 = "หนึ่งล้าน", 1,000,001,000 = "หนึ่งล้านหนึ่งล้าน")

Unit Words

  • "บาท" - Currency unit (Baht)
  • "สตางค์" - Fractional unit (Satang)
  • "ถ้วน" - Exact/full indicator (used when satang is zero)

Examples


 handler.convert(ThaiBaht.of(new BigDecimal("100.00"), config));
 // Output: "หนึ่งร้อยบาทถ้วน"

 handler.convert(ThaiBaht.of(new BigDecimal("1234.56"), config));
 // Output: "หนึ่งพันสองร้อยสามสิบสี่บาทห้าสิบหกสตางค์"
 
Since:
2.0.0
Author:
Zazalng
See Also:
  • Constructor Details

    • ThaiLanguageHandler

      public ThaiLanguageHandler()
  • Method Details

    • convert

      public String convert(ThaiBaht baht)
      Description copied from interface: LanguageHandler
      Converts the amount in the given ThaiBaht instance to language-specific text.

      The implementation must respect the configuration options from baht.getConfig(), including unit word inclusion, custom format templates, and negative prefix settings.

      Specified by:
      convert in interface LanguageHandler
      Parameters:
      baht - the ThaiBaht instance containing amount and configuration, never null
      Returns:
      the language-specific textual representation of the amount, never null
    • getLanguageCode

      public String getLanguageCode()
      Description copied from interface: LanguageHandler
      Returns the language code identifier for this handler.

      This is typically a two or three-letter ISO 639 code (e.g., "th" for Thai, "en" for English).

      Specified by:
      getLanguageCode in interface LanguageHandler
      Returns:
      the language code, never null or empty
    • getLanguageName

      public String getLanguageName()
      Description copied from interface: LanguageHandler
      Returns the human-readable name of this language.

      This is typically used for display and identification purposes.

      Specified by:
      getLanguageName in interface LanguageHandler
      Returns:
      the language name (e.g., "Thai", "English"), never null or empty
    • getUnitWord

      public String getUnitWord()
      Description copied from interface: LanguageHandler
      Returns the currency unit word for the integer (baht) part.

      Examples:

      • Thai: "บาท" (Baht)
      • English: "Baht"
      • Laotian: "ກີບ" (Kip)
      Specified by:
      getUnitWord in interface LanguageHandler
      Returns:
      the unit word, never null or empty
    • getExactWord

      public String getExactWord()
      Description copied from interface: LanguageHandler
      Returns the exact/only indicator word displayed when satang (fractional part) is zero.

      Examples:

      • Thai: "ถ้วน" (Exact/Full)
      • English: "Only"
      Specified by:
      getExactWord in interface LanguageHandler
      Returns:
      the exact indicator word, never null or empty
    • getSatangWord

      public String getSatangWord()
      Description copied from interface: LanguageHandler
      Returns the satang (fractional currency unit) word.

      Examples:

      • Thai: "สตางค์" (Satang)
      • English: "Satang"
      Specified by:
      getSatangWord in interface LanguageHandler
      Returns:
      the satang unit word, never null or empty
    • getNegativePrefix

      public String getNegativePrefix()
      Description copied from interface: LanguageHandler
      Returns the default prefix applied to negative amounts.

      This prefix is used when the amount is negative, unless explicitly overridden via ThaiBahtConfig.Builder.setPrefix(String).

      Examples:

      • Thai: "ลบ" (Thai minus symbol)
      • English: "Minus"
      Specified by:
      getNegativePrefix in interface LanguageHandler
      Returns:
      the negative prefix, never null or empty