io.github.freya022.botcommands.api.localization.arguments.MessageFormatArgument.kt Maven / Gradle / Ivy
package io.github.freya022.botcommands.api.localization.arguments
import java.text.MessageFormat
import java.util.*
import java.util.concurrent.locks.ReentrantLock
import kotlin.concurrent.withLock
class MessageFormatArgument(
override val argumentName: String,
formatter: String,
locale: Locale
) : FormattableArgument {
private val lock = ReentrantLock()
private val formatter = MessageFormat(formatter, locale)
override fun format(obj: Any): String = lock.withLock { formatter.format(arrayOf(obj)) }
override fun toString(): String {
return "MessageFormatArgument(argumentName='$argumentName', formatter=${formatter.toPattern()})"
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy