forked from openrs2/openrs2
parent
485a784b53
commit
879e3152fc
@ -1,29 +0,0 @@ |
||||
package dev.openrs2.util; |
||||
|
||||
import com.google.common.base.Preconditions; |
||||
|
||||
public final class StringUtils { |
||||
public static String indefiniteArticle(String str) { |
||||
Preconditions.checkArgument(!str.isEmpty()); |
||||
|
||||
var first = Character.toLowerCase(str.charAt(0)); |
||||
if (first == 'a' || first == 'e' || first == 'i' || first == 'o' || first == 'u') { |
||||
return "an"; |
||||
} else { |
||||
return "a"; |
||||
} |
||||
} |
||||
|
||||
public static String capitalize(String str) { |
||||
if (str.isEmpty()) { |
||||
return str; |
||||
} |
||||
|
||||
var first = Character.toUpperCase(str.charAt(0)); |
||||
return first + str.substring(1); |
||||
} |
||||
|
||||
private StringUtils() { |
||||
/* empty */ |
||||
} |
||||
} |
@ -0,0 +1,20 @@ |
||||
package dev.openrs2.util |
||||
|
||||
object StringUtils { |
||||
// TODO(gpe): convert to an extension function |
||||
@JvmStatic |
||||
fun indefiniteArticle(str: String): String { |
||||
require(str.isNotEmpty()) |
||||
|
||||
val first = str.first().toLowerCase() |
||||
return when (first) { |
||||
'a', 'e', 'i', 'o', 'u' -> "an" |
||||
else -> "a" |
||||
} |
||||
} |
||||
|
||||
@JvmStatic |
||||
fun capitalize(str: String): String { |
||||
return str.capitalize() |
||||
} |
||||
} |
Loading…
Reference in new issue