org.bbottema.javareflection.util.commonslang25.StringUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-reflection Show documentation
Show all versions of java-reflection Show documentation
Java Reflection provides a small package with nifty reflection features that will help with finding constructors, methods and value conversions
package org.bbottema.javareflection.util.commonslang25;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
@SuppressFBWarnings(justification = "imported code as-is from Apache Commons Lang 2.5")
public class StringUtils {
private StringUtils() {
}
/**
* Capitalizes a String changing the first letter to title case as
* per {@link Character#toTitleCase(char)}. No other letters are changed.
*
* For a word based algorithm, see WordUtils#capitalize(String).
* A null
input String returns null
.
*
*
* StringUtils.capitalize(null) = null
* StringUtils.capitalize("") = ""
* StringUtils.capitalize("cat") = "Cat"
* StringUtils.capitalize("cAt") = "CAt"
*
*
* @param str the String to capitalize, may be null
*
* @return the capitalized String, null
if null String input
* @since 2.0
*/
public static String capitalize(String str) {
if (str == null || str.length() == 0) {
return str;
}
return String.valueOf(Character.toTitleCase(str.charAt(0))) + str.substring(1);
}
}