|
1 | 1 | package com.auritylab.graphql.kotlin.toolkit.codegen.helper |
2 | 2 |
|
| 3 | +/** |
| 4 | + * A global helper object which provides some common used methods to work with strings. |
| 5 | + */ |
3 | 6 | internal object NamingHelper { |
4 | 7 | /** |
5 | | - * Will uppercase the first letter of the given [string]. |
6 | | - * If the given [string] is `getUser` this method will return `GetUser`. |
| 8 | + * Will uppercase the first letter of the given [String]. To be more precise, if [i] is "getUser", this method |
| 9 | + * will return "GetUser". |
| 10 | + * |
| 11 | + * @param i The string which shall be transformed. |
| 12 | + * @return The transformed string. |
7 | 13 | */ |
8 | | - fun uppercaseFirstLetter(string: String): String = |
9 | | - (string.substring(0, 1).toUpperCase()) + string.substring(1) |
| 14 | + fun uppercaseFirstLetter(i: String): String = (i.substring(0, 1).toUpperCase()) + i.substring(1) |
| 15 | + |
| 16 | + /** |
| 17 | + * Will lowercase the first letter for the given [String]. To be more precise, if [i] is "GetUser", this method |
| 18 | + * will return "getUser" |
| 19 | + * @param i The string which shall be transformed. |
| 20 | + * @return The transformed string. |
| 21 | + */ |
| 22 | + fun lowercaseFirstLetter(i: String): String = (i.substring(0, 1).toLowerCase()) + i.substring(1) |
10 | 23 | } |
| 24 | + |
| 25 | +/** |
| 26 | + * Extension function which delegates to [NamingHelper.uppercaseFirstLetter]. |
| 27 | + * |
| 28 | + * @see NamingHelper.uppercaseFirstLetter |
| 29 | + */ |
| 30 | +internal fun String.uppercaseFirst(): String = NamingHelper.uppercaseFirstLetter(this) |
| 31 | + |
| 32 | +/** |
| 33 | + * Extension function which delegates to [NamingHelper.lowercaseFirstLetter]. |
| 34 | + * |
| 35 | + * @see NamingHelper.lowercaseFirstLetter |
| 36 | + */ |
| 37 | +internal fun String.lowercaseFirst(): String = NamingHelper.lowercaseFirstLetter(this) |
0 commit comments