2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.jeelink.internal.util;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
18 * Utility class for strings
20 * @author Leo Siepel - Initial contribution
23 public final class StringUtils {
27 * Capitalizes a String changing the first character to title case.
28 * No other characters are changed.
32 * StringUtils.capitalize(null) = null
33 * StringUtils.capitalize("") = ""
34 * StringUtils.capitalize("cat") = "Cat"
35 * StringUtils.capitalize("cAt") = "CAt"
36 * StringUtils.capitalize("'cat'") = "'cat'"
39 * @param val the String to capitalize, may not be null
40 * @return the capitalized String
42 public static String capitalize(String val) {
43 if (val.length() == 0) {
46 return val.substring(0, 1).toUpperCase() + val.substring(1);