MCPcopy Create free account
hub / github.com/apache/groovy / capitalize

Method capitalize

src/main/java/org/apache/groovy/util/BeanUtils.java:61–70  ·  view source on GitHub ↗

This is the complement the behavior of the decapitalize(String) method. We handle names that begin with an initial lowerCase followed by upperCase with special JavaBean behavior (which is to make no change). See GROOVY-3211. @param property the property name to capitalize @return the name capitaliz

(final String property)

Source from the content-addressed store, hash-verified

59 * @since 3.0.0
60 */
61 public static String capitalize(final String property) {
62 int propertyLength = (property == null ? 0 : property.length());
63 if (propertyLength == 0 || !Character.isLowerCase(property.charAt(0))
64 || (propertyLength > 1 && Character.isUpperCase(property.charAt(1)))) {
65 return property;
66 }
67 final char[] c = property.toCharArray();
68 c[0] = Character.toUpperCase(c[0]);
69 return new String(c);
70 }
71
72 private BeanUtils() {
73 }

Callers 9

visitPropertyMethod · 0.95
capitalizeMethod · 0.95
capitalizeMethod · 0.95
getPropertyGetterNameMethod · 0.45
getGetterNameMethod · 0.45
getSetterNameMethod · 0.45
resolveClassnameMethod · 0.45
makeClassNameMethod · 0.45

Calls 6

isLowerCaseMethod · 0.80
isUpperCaseMethod · 0.80
toCharArrayMethod · 0.65
lengthMethod · 0.45
charAtMethod · 0.45
toUpperCaseMethod · 0.45

Tested by

no test coverage detected