Skip to content

Commit

Permalink
[#52] allow 10 instead of 5 parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
comahe-de committed Nov 17, 2023
1 parent 90bf7ff commit f0e4216
Show file tree
Hide file tree
Showing 10 changed files with 392 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,15 @@ import de.comahe.i18n4k.messages.providers.MessagesProvider
import de.comahe.i18n4k.messages.providers.MessagesProviderFactory
import de.comahe.i18n4k.strings.AbstractLocalizedString
import de.comahe.i18n4k.strings.LocalizedString
import kotlinx.atomicfu.AtomicArray
import kotlinx.atomicfu.AtomicRef
import kotlinx.atomicfu.atomic
import kotlinx.atomicfu.atomicArrayOfNulls
import kotlinx.atomicfu.update
import kotlinx.collections.immutable.PersistentList
import kotlinx.collections.immutable.PersistentMap
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.persistentMapOf
import kotlinx.collections.immutable.toPersistentList
import kotlinx.collections.immutable.toPersistentMap
import kotlin.math.max

/**
* Base class for bundles of messages.
Expand Down Expand Up @@ -192,6 +189,37 @@ open class MessageBundle(
key: String, index: Int, p0: Any, p1: Any, p2: Any, p3: Any, p4: Any
): MessageBundleLocalizedString = LocalizedStringN(this, key, index, listOf(p0, p1, p2, p3, p4))

/** See [getLocalizedString1], but with 6 parameters. */
protected fun getLocalizedString6(
key: String, index: Int, p0: Any, p1: Any, p2: Any, p3: Any, p4: Any, p5: Any,
): MessageBundleLocalizedString =
LocalizedStringN(this, key, index, listOf(p0, p1, p2, p3, p4, p5))

/** See [getLocalizedString1], but with 7 parameters. */
protected fun getLocalizedString7(
key: String, index: Int, p0: Any, p1: Any, p2: Any, p3: Any, p4: Any, p5: Any, p6: Any,
): MessageBundleLocalizedString =
LocalizedStringN(this, key, index, listOf(p0, p1, p2, p3, p4, p5, p6))

/** See [getLocalizedString1], but with 8 parameters. */
protected fun getLocalizedString8(
key: String, index: Int, p0: Any, p1: Any, p2: Any, p3: Any, p4: Any, p5: Any, p6: Any, p7: Any,
): MessageBundleLocalizedString =
LocalizedStringN(this, key, index, listOf(p0, p1, p2, p3, p4, p5, p6, p7))

/** See [getLocalizedString1], but with 9 parameters. */
protected fun getLocalizedString9(
key: String, index: Int, p0: Any, p1: Any, p2: Any, p3: Any, p4: Any, p5: Any, p6: Any, p7: Any, p8: Any,
): MessageBundleLocalizedString =
LocalizedStringN(this, key, index, listOf(p0, p1, p2, p3, p4, p5, p6, p7, p8))

/** See [getLocalizedString1], but with 10 parameters. */
protected fun getLocalizedString10(
key: String, index: Int, p0: Any, p1: Any, p2: Any, p3: Any, p4: Any, p5: Any, p6: Any, p7: Any, p8: Any, p9: Any,
): MessageBundleLocalizedString =
LocalizedStringN(this, key, index, listOf(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9))


/**
* Create a factory for [LocalizedString] for the given index.
*
Expand Down Expand Up @@ -233,6 +261,41 @@ open class MessageBundle(
): MessageBundleLocalizedStringFactory5 =
LocalizedStringFactory5Bundled(this, key, index)

/** See [getLocalizedStringFactory1], but with 6 parameters. */
protected fun getLocalizedStringFactory6(
key: String,
index: Int
): MessageBundleLocalizedStringFactory6 =
LocalizedStringFactory6Bundled(this, key, index)

/** See [getLocalizedStringFactory1], but with 7 parameters. */
protected fun getLocalizedStringFactory7(
key: String,
index: Int
): MessageBundleLocalizedStringFactory7 =
LocalizedStringFactory7Bundled(this, key, index)

/** See [getLocalizedStringFactory1], but with 8 parameters. */
protected fun getLocalizedStringFactory8(
key: String,
index: Int
): MessageBundleLocalizedStringFactory8 =
LocalizedStringFactory8Bundled(this, key, index)

/** See [getLocalizedStringFactory1], but with 9 parameters. */
protected fun getLocalizedStringFactory9(
key: String,
index: Int
): MessageBundleLocalizedStringFactory9 =
LocalizedStringFactory9Bundled(this, key, index)

/** See [getLocalizedStringFactory1], but with 10 parameters. */
protected fun getLocalizedStringFactory10(
key: String,
index: Int
): MessageBundleLocalizedStringFactory10 =
LocalizedStringFactory10Bundled(this, key, index)


////////////////////////////////////////////////////////////
// LocalizedString
Expand Down Expand Up @@ -412,4 +475,99 @@ open class MessageBundle(
messageBundle.getLocalizedString5(messageKey, messageIndex, p0, p1, p2, p3, p4)

}

private data class LocalizedStringFactory6Bundled(
override val messageBundle: MessageBundle,
override val messageKey: String,
override val messageIndex: Int
) : MessageBundleLocalizedStringFactory6 {

override fun toString() =
toString(null)

fun toString(locale: Locale?) =
messageBundle.getString0(messageIndex, locale)

override fun createString(p0: Any, p1: Any, p2: Any, p3: Any, p4: Any, p5: Any, locale: Locale?) =
messageBundle.getStringN(messageIndex, listOf(p0, p1, p2, p3, p4, p5), locale)

override fun createLocalizedString(p0: Any, p1: Any, p2: Any, p3: Any, p4: Any, p5: Any) =
messageBundle.getLocalizedString6(messageKey, messageIndex, p0, p1, p2, p3, p4, p5)
}

private data class LocalizedStringFactory7Bundled(
override val messageBundle: MessageBundle,
override val messageKey: String,
override val messageIndex: Int
) : MessageBundleLocalizedStringFactory7 {

override fun toString() =
toString(null)

fun toString(locale: Locale?) =
messageBundle.getString0(messageIndex, locale)

override fun createString(p0: Any, p1: Any, p2: Any, p3: Any, p4: Any, p5: Any, p6: Any, locale: Locale?) =
messageBundle.getStringN(messageIndex, listOf(p0, p1, p2, p3, p4, p5, p6), locale)

override fun createLocalizedString(p0: Any, p1: Any, p2: Any, p3: Any, p4: Any, p5: Any, p6: Any) =
messageBundle.getLocalizedString7(messageKey, messageIndex, p0, p1, p2, p3, p4, p5, p6)
}

private data class LocalizedStringFactory8Bundled(
override val messageBundle: MessageBundle,
override val messageKey: String,
override val messageIndex: Int
) : MessageBundleLocalizedStringFactory8 {

override fun toString() =
toString(null)

fun toString(locale: Locale?) =
messageBundle.getString0(messageIndex, locale)

override fun createString(p0: Any, p1: Any, p2: Any, p3: Any, p4: Any, p5: Any, p6: Any, p7: Any, locale: Locale?) =
messageBundle.getStringN(messageIndex, listOf(p0, p1, p2, p3, p4, p5, p6, p7), locale)

override fun createLocalizedString(p0: Any, p1: Any, p2: Any, p3: Any, p4: Any, p5: Any, p6: Any, p7: Any) =
messageBundle.getLocalizedString8(messageKey, messageIndex, p0, p1, p2, p3, p4, p5, p6, p7)
}

private data class LocalizedStringFactory9Bundled(
override val messageBundle: MessageBundle,
override val messageKey: String,
override val messageIndex: Int
) : MessageBundleLocalizedStringFactory9 {

override fun toString() =
toString(null)

fun toString(locale: Locale?) =
messageBundle.getString0(messageIndex, locale)

override fun createString(p0: Any, p1: Any, p2: Any, p3: Any, p4: Any, p5: Any, p6: Any, p7: Any, p8: Any, locale: Locale?) =
messageBundle.getStringN(messageIndex, listOf(p0, p1, p2, p3, p4, p5, p6, p7, p8), locale)

override fun createLocalizedString(p0: Any, p1: Any, p2: Any, p3: Any, p4: Any, p5: Any, p6: Any, p7: Any, p8: Any) =
messageBundle.getLocalizedString9(messageKey, messageIndex, p0, p1, p2, p3, p4, p5, p6, p7, p8)
}

private data class LocalizedStringFactory10Bundled(
override val messageBundle: MessageBundle,
override val messageKey: String,
override val messageIndex: Int
) : MessageBundleLocalizedStringFactory10 {

override fun toString() =
toString(null)

fun toString(locale: Locale?) =
messageBundle.getString0(messageIndex, locale)

override fun createString(p0: Any, p1: Any, p2: Any, p3: Any, p4: Any, p5: Any, p6: Any, p7: Any, p8: Any, p9: Any, locale: Locale?) =
messageBundle.getStringN(messageIndex, listOf(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9), locale)

override fun createLocalizedString(p0: Any, p1: Any, p2: Any, p3: Any, p4: Any, p5: Any, p6: Any, p7: Any, p8: Any, p9: Any) =
messageBundle.getLocalizedString10(messageKey, messageIndex, p0, p1, p2, p3, p4, p5, p8, p7, p8, p9)
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
package de.comahe.i18n4k.messages

import de.comahe.i18n4k.strings.LocalizedStringFactory1
import de.comahe.i18n4k.strings.LocalizedStringFactory10
import de.comahe.i18n4k.strings.LocalizedStringFactory2
import de.comahe.i18n4k.strings.LocalizedStringFactory3
import de.comahe.i18n4k.strings.LocalizedStringFactory4
import de.comahe.i18n4k.strings.LocalizedStringFactory5
import de.comahe.i18n4k.strings.LocalizedStringFactory6
import de.comahe.i18n4k.strings.LocalizedStringFactory7
import de.comahe.i18n4k.strings.LocalizedStringFactory8
import de.comahe.i18n4k.strings.LocalizedStringFactory9

interface MessageBundleLocalizedStringFactory1 : LocalizedStringFactory1, MessageBundleEntry
interface MessageBundleLocalizedStringFactory2 : LocalizedStringFactory2, MessageBundleEntry
interface MessageBundleLocalizedStringFactory3 : LocalizedStringFactory3, MessageBundleEntry
interface MessageBundleLocalizedStringFactory4 : LocalizedStringFactory4, MessageBundleEntry
interface MessageBundleLocalizedStringFactory5 : LocalizedStringFactory5, MessageBundleEntry
interface MessageBundleLocalizedStringFactory5 : LocalizedStringFactory5, MessageBundleEntry
interface MessageBundleLocalizedStringFactory6 : LocalizedStringFactory6, MessageBundleEntry
interface MessageBundleLocalizedStringFactory7 : LocalizedStringFactory7, MessageBundleEntry
interface MessageBundleLocalizedStringFactory8 : LocalizedStringFactory8, MessageBundleEntry
interface MessageBundleLocalizedStringFactory9 : LocalizedStringFactory9, MessageBundleEntry
interface MessageBundleLocalizedStringFactory10 : LocalizedStringFactory10, MessageBundleEntry
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,135 @@ interface LocalizedStringFactory5 {
/** Shortcut for [createLocalizedString] */
operator fun get(p0: Any, p1: Any, p2: Any, p3: Any, p4: Any): LocalizedString =
createLocalizedString(p0, p1, p2, p3, p4)
}

/** See [LocalizedStringFactory1], but with 6 parameters. */
interface LocalizedStringFactory6 {

/** Create a string with the given parameter.
*
* @see [LocalizedStringFactory1.createString]]
* */
fun createString(p0: Any, p1: Any, p2: Any, p3: Any, p4: Any, p5: Any, locale: Locale? = null): String

/** Create [LocalizedString] with the given parameter
*
* @see [LocalizedStringFactory1.createLocalizedString]]
*/
fun createLocalizedString(p0: Any, p1: Any, p2: Any, p3: Any, p4: Any, p5: Any): LocalizedString

/** Shortcut for [createString] */
operator fun invoke(
p0: Any, p1: Any, p2: Any, p3: Any, p4: Any, p5: Any,
locale: Locale? = null
): String =
createString(p0, p1, p2, p3, p4, p5, locale)

/** Shortcut for [createLocalizedString] */
operator fun get(p0: Any, p1: Any, p2: Any, p3: Any, p4: Any, p5: Any): LocalizedString =
createLocalizedString(p0, p1, p2, p3, p4, p5)
}

interface LocalizedStringFactory7 {

/** Create a string with the given parameter.
*
* @see [LocalizedStringFactory1.createString]]
* */
fun createString(p0: Any, p1: Any, p2: Any, p3: Any, p4: Any, p5: Any, p6: Any, locale: Locale? = null): String

/** Create [LocalizedString] with the given parameter
*
* @see [LocalizedStringFactory1.createLocalizedString]]
*/
fun createLocalizedString(p0: Any, p1: Any, p2: Any, p3: Any, p4: Any, p5: Any, p6: Any): LocalizedString

/** Shortcut for [createString] */
operator fun invoke(
p0: Any, p1: Any, p2: Any, p3: Any, p4: Any, p5: Any, p6: Any,
locale: Locale? = null
): String =
createString(p0, p1, p2, p3, p4, p5, p6, locale)

/** Shortcut for [createLocalizedString] */
operator fun get(p0: Any, p1: Any, p2: Any, p3: Any, p4: Any, p5: Any, p6: Any): LocalizedString =
createLocalizedString(p0, p1, p2, p3, p4, p5, p6)
}

interface LocalizedStringFactory8 {

/** Create a string with the given parameter.
*
* @see [LocalizedStringFactory1.createString]]
* */
fun createString(p0: Any, p1: Any, p2: Any, p3: Any, p4: Any, p5: Any, p6: Any, p7: Any, locale: Locale? = null): String

/** Create [LocalizedString] with the given parameter
*
* @see [LocalizedStringFactory1.createLocalizedString]]
*/
fun createLocalizedString(p0: Any, p1: Any, p2: Any, p3: Any, p4: Any, p5: Any, p6: Any, p7: Any): LocalizedString

/** Shortcut for [createString] */
operator fun invoke(
p0: Any, p1: Any, p2: Any, p3: Any, p4: Any, p5: Any, p6: Any, p7: Any,
locale: Locale? = null
): String =
createString(p0, p1, p2, p3, p4, p5, p6, p7, locale)

/** Shortcut for [createLocalizedString] */
operator fun get(p0: Any, p1: Any, p2: Any, p3: Any, p4: Any, p5: Any, p6: Any, p7: Any): LocalizedString =
createLocalizedString(p0, p1, p2, p3, p4, p5, p6, p7)
}

interface LocalizedStringFactory9 {

/** Create a string with the given parameter.
*
* @see [LocalizedStringFactory1.createString]]
* */
fun createString(p0: Any, p1: Any, p2: Any, p3: Any, p4: Any, p5: Any, p6: Any, p7: Any, p8: Any, locale: Locale? = null): String

/** Create [LocalizedString] with the given parameter
*
* @see [LocalizedStringFactory1.createLocalizedString]]
*/
fun createLocalizedString(p0: Any, p1: Any, p2: Any, p3: Any, p4: Any, p5: Any, p6: Any, p7: Any, p8: Any): LocalizedString

/** Shortcut for [createString] */
operator fun invoke(
p0: Any, p1: Any, p2: Any, p3: Any, p4: Any, p5: Any, p6: Any, p7: Any, p8: Any,
locale: Locale? = null
): String =
createString(p0, p1, p2, p3, p4, p5, p6, p7, p8, locale)

/** Shortcut for [createLocalizedString] */
operator fun get(p0: Any, p1: Any, p2: Any, p3: Any, p4: Any, p5: Any, p6: Any, p7: Any, p8: Any): LocalizedString =
createLocalizedString(p0, p1, p2, p3, p4, p5, p6, p7, p8)
}

interface LocalizedStringFactory10 {

/** Create a string with the given parameter.
*
* @see [LocalizedStringFactory1.createString]]
* */
fun createString(p0: Any, p1: Any, p2: Any, p3: Any, p4: Any, p5: Any, p6: Any, p7: Any, p8: Any, p9: Any, locale: Locale? = null): String

/** Create [LocalizedString] with the given parameter
*
* @see [LocalizedStringFactory1.createLocalizedString]]
*/
fun createLocalizedString(p0: Any, p1: Any, p2: Any, p3: Any, p4: Any, p5: Any, p6: Any, p7: Any, p8: Any, p9: Any): LocalizedString

/** Shortcut for [createString] */
operator fun invoke(
p0: Any, p1: Any, p2: Any, p3: Any, p4: Any, p5: Any, p6: Any, p7: Any, p8: Any, p9: Any,
locale: Locale? = null
): String =
createString(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, locale)

/** Shortcut for [createLocalizedString] */
operator fun get(p0: Any, p1: Any, p2: Any, p3: Any, p4: Any, p5: Any, p6: Any, p7: Any, p8: Any, p9: Any): LocalizedString =
createLocalizedString(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)
}
Loading

0 comments on commit f0e4216

Please sign in to comment.