|
| 1 | +/* |
| 2 | + * Copyright 2024, TeamDev. All rights reserved. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Redistribution and use in source and/or binary forms, with or without |
| 11 | + * modification, must retain the above copyright notice and the following |
| 12 | + * disclaimer. |
| 13 | + * |
| 14 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 15 | + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 16 | + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 17 | + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 18 | + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 19 | + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 20 | + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 21 | + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 22 | + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 23 | + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 | + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 | + */ |
| 26 | + |
| 27 | +import org.gradle.configurationcache.extensions.capitalized |
| 28 | + |
| 29 | +/** |
| 30 | + * This file provides extensions to `String` and `CharSequence` that wrap |
| 31 | + * analogues from standard Kotlin runtime. |
| 32 | + * |
| 33 | + * It helps in switching between versions of Gradle which have different versions of |
| 34 | + * the Kotlin runtime. Please see the bodies of the extension functions for details on |
| 35 | + * switching the implementations depending on the Kotlin version at hand. |
| 36 | + * |
| 37 | + * Once we migrate to newer Gradle, these wrappers should be inlined with |
| 38 | + * the subsequent removal of this source file. |
| 39 | + */ |
| 40 | +@Suppress("unused") |
| 41 | +private const val ABOUT = "" |
| 42 | + |
| 43 | +/** |
| 44 | + * Makes the first character come in the title case. |
| 45 | + */ |
| 46 | +fun String.titleCaseFirstChar(): String { |
| 47 | + // return replaceFirstChar { it.titlecase() } |
| 48 | + // OR for earlier Kotlin versions: |
| 49 | + // 1. add import of `org.gradle.configurationcache.extensions.capitalized` |
| 50 | + // 2. call `capitalized()` instead of `replaceFirstChar` above. |
| 51 | + return capitalized() |
| 52 | +} |
| 53 | + |
| 54 | +/** |
| 55 | + * Converts this string to lowercase. |
| 56 | + */ |
| 57 | +fun String.lowercased(): String { |
| 58 | + // return lowercase() |
| 59 | + // OR for earlier Kotlin versions call: |
| 60 | + return toLowerCase() |
| 61 | +} |
0 commit comments