Here you can find the source of valueOfOrEmptyString(final Object object)
Parameter | Description |
---|---|
object | an object. |
public static String valueOfOrEmptyString(final Object object)
//package com.java2s; /*// w ww . ja v a 2 s.c om * Copyright 2011-2015 B2i Healthcare Pte Ltd, http://b2i.sg * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License 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. */ public class Main { /**Shared empty string.*/ public static final String EMPTY_STRING = ""; /** * Returns with an empty string is the argument is {@code null} otherwise * returns with {@link String#valueOf(Object)}. * @param object an object. * @return empty string is the object is {@code null} otherwise with the * {@link Object#toString()} of the argument. */ public static String valueOfOrEmptyString(final Object object) { return null == object ? EMPTY_STRING : String.valueOf(object); } }