All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.eclipse.persistence.internal.helper.StringHelper Maven / Gradle / Ivy

There is a newer version: 4.0.2
Show newest version
/*
 * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v. 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0,
 * or the Eclipse Distribution License v. 1.0 which is available at
 * http://www.eclipse.org/org/documents/edl-v10.php.
 *
 * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
 */

// Contributors:
//     Tomas Kraus - Initial API and implementation
package org.eclipse.persistence.internal.helper;

/**
 * INTERNAL:
 * 

Purpose: Define any useful {@link String} constants and methods that are missing from the base Java.

*/ public class StringHelper { /** Horizontal tab. */ public static final char TAB = '\t'; /** Line feed. */ public static final char LF = '\n'; /** Form feed */ public static final char FF = '\f'; /** Carriage return */ public static final char CR = '\r'; /** Space. */ public static final char SPACE = ' '; /** Left brace. */ public static final char LEFT_BRACE = '{'; /** Right brace. */ public static final char RIGHT_BRACE = '}'; /** Left bracket. */ public static final char LEFT_BRACKET = '('; /** Right bracket. */ public static final char RIGHT_BRACKET = ')'; /** Dot. */ public static final char DOT = '.'; /** Vertical bar. */ public static final char VERTICAL_BAR = '|'; /** Vertical bar. */ public static final char QUESTION_MARK = '?'; /** Empty {@link String}. */ public static final String EMPTY_STRING = ""; /** "null" {@link String}. */ public static final String NULL_STRING = "null"; /** * Never return null but replace it with "null" {@link String}. * @param str String to be checked for null and eventually replaced with * "null" {@link String}. * @return Provided string when not null or "null" {@link String}. */ public static final String nonNullString(String str) { return str != null ? str : NULL_STRING; } /** * Checks if {@link String} is {@code null}, is empty ({@code ""}) or contains white spaces only. * @param str {@link String} to be checked. * @return Value of {@code true} if @link String} is {@code null}, is empty ({@code ""}) or contains white spaces * only or {@code false} otherwise */ public static final boolean isBlank(final String str) { return str == null || str.trim().length() == 0; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy