| /* | |
| * Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. | |
| * | |
| * Licensed under the Apache License, Version 2.0 (the "License"). | |
| * You may not use this file except in compliance with the License. | |
| * A copy of the License is located at | |
| * | |
| * http://aws.amazon.com/apache2.0 | |
| * | |
| * or in the "license" file accompanying this file. This file is distributed | |
| * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | |
| * express or implied. See the License for the specific language governing | |
| * permissions and limitations under the License. | |
| */ | |
| package com.amazonaws.util; | |
| import java.nio.charset.Charset; | |
| /** | |
| * Utilities for converting objects to strings. | |
| */ | |
| public class StringUtils { | |
| private static final String DEFAULT_ENCODING = "UTF-8"; | |
| public static final Charset UTF8 = Charset.forName(DEFAULT_ENCODING); | |
| /** | |
| * A null-safe trim method. If the input string is null, returns null; | |
| * otherwise returns a trimmed version of the input. | |
| */ | |
| public static String trim(String value) { | |
| if (value == null) { | |
| return null; | |
| } | |
| return value.trim(); | |
| } | |
| /** | |
| * @return true if the given value is either null or the empty string | |
| */ | |
| public static boolean isNullOrEmpty(String value) { | |
| return value == null || value.isEmpty(); | |
| } | |
| } |