View Javadoc

1   /*
2    * Copyright 2009-2010 Steve Chaloner
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package be.objectify.led.util;
17  
18  /**
19   * Utility methods for working with strings.
20   *
21   * @author Steve Chaloner
22   */
23  public class StringUtils
24  {
25      private StringUtils()
26      {
27      }
28  
29      /**
30       * Checks if the given string is null or comprised entirely of whitespace.
31       *
32       * @param string the string to check
33       * @return true iff the string is null or empty
34       */
35      public static boolean isEmpty(String string)
36      {
37          return string == null || string.trim().length() == 0;
38      }
39  }