]> git.basschouten.com Git - openhab-addons.git/blob
d5d93335f392ca5a72ba7eebdcd5cc82f788430e
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.jeelink.internal.util;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16
17 /**
18  * Utility class for strings
19  *
20  * @author Leo Siepel - Initial contribution
21  */
22 @NonNullByDefault
23 public final class StringUtils {
24
25     /**
26      * <p>
27      * Capitalizes a String changing the first character to title case.
28      * No other characters are changed.
29      * </p>
30      *
31      * <pre>
32      * StringUtils.capitalize(null)  = null
33      * StringUtils.capitalize("")    = ""
34      * StringUtils.capitalize("cat") = "Cat"
35      * StringUtils.capitalize("cAt") = "CAt"
36      * StringUtils.capitalize("'cat'") = "'cat'"
37      * </pre>
38      *
39      * @param val the String to capitalize, may not be null
40      * @return the capitalized String
41      */
42     public static String capitalize(String val) {
43         if (val.length() == 0) {
44             return val;
45         }
46         return val.substring(0, 1).toUpperCase() + val.substring(1);
47     }
48 }