Class ThaiLanguageHandler
- All Implemented Interfaces:
LanguageHandler
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionConverts the amount in the givenThaiBahtinstance to language-specific text.Returns the exact/only indicator word displayed when satang (fractional part) is zero.Returns the language code identifier for this handler.Returns the human-readable name of this language.Returns the default prefix applied to negative amounts.Returns the satang (fractional currency unit) word.Returns the currency unit word for the integer (baht) part.
-
Constructor Details
-
ThaiLanguageHandler
public ThaiLanguageHandler()
-
-
Method Details
-
convert
Description copied from interface:LanguageHandlerConverts the amount in the givenThaiBahtinstance 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:
convertin interfaceLanguageHandler- Parameters:
baht- theThaiBahtinstance containing amount and configuration, never null- Returns:
- the language-specific textual representation of the amount, never null
-
getLanguageCode
Description copied from interface:LanguageHandlerReturns 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:
getLanguageCodein interfaceLanguageHandler- Returns:
- the language code, never null or empty
-
getLanguageName
Description copied from interface:LanguageHandlerReturns the human-readable name of this language.This is typically used for display and identification purposes.
- Specified by:
getLanguageNamein interfaceLanguageHandler- Returns:
- the language name (e.g., "Thai", "English"), never null or empty
-
getUnitWord
Description copied from interface:LanguageHandlerReturns the currency unit word for the integer (baht) part.Examples:
- Thai: "บาท" (Baht)
- English: "Baht"
- Laotian: "ກີບ" (Kip)
- Specified by:
getUnitWordin interfaceLanguageHandler- Returns:
- the unit word, never null or empty
-
getExactWord
Description copied from interface:LanguageHandlerReturns the exact/only indicator word displayed when satang (fractional part) is zero.Examples:
- Thai: "ถ้วน" (Exact/Full)
- English: "Only"
- Specified by:
getExactWordin interfaceLanguageHandler- Returns:
- the exact indicator word, never null or empty
-
getSatangWord
Description copied from interface:LanguageHandlerReturns the satang (fractional currency unit) word.Examples:
- Thai: "สตางค์" (Satang)
- English: "Satang"
- Specified by:
getSatangWordin interfaceLanguageHandler- Returns:
- the satang unit word, never null or empty
-
getNegativePrefix
Description copied from interface:LanguageHandlerReturns 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:
getNegativePrefixin interfaceLanguageHandler- Returns:
- the negative prefix, never null or empty
-