1 /*******************************************************************************
2 * Copyright (c) 2014 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Alexandre Montplaisir - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.common
.core
;
15 import org
.eclipse
.jdt
.annotation
.NonNull
;
16 import org
.eclipse
.jdt
.annotation
.Nullable
;
19 * Utility methods to handle {@link org.eclipse.jdt.annotation.NonNull}
22 * @author Alexandre Montplaisir
24 public final class NonNullUtils
{
26 private NonNullUtils() {}
29 * Convert a potentially null string into an empty one if it is null.
32 * The string to null-check, and convert to an empty string if
34 * @return The non-null string
36 public static String
nullToEmptyString(@Nullable String str
) {
38 return ""; //$NON-NLS-1$
44 * Convert a non-annotated object reference to a {@link NonNull} one.
46 * If the reference is actually null, a {@link NullPointerException} is
47 * thrown. This is usually more desirable than letting an unwanted null
48 * reference go through and fail much later.
51 * The object that is supposed to be non-null
52 * @return A {@link NonNull} reference to the same object
53 * @throws NullPointerException
54 * If the reference was actually null
56 public static <T
> T
checkNotNull(@Nullable T obj
) {
58 throw new NullPointerException();
This page took 0.035421 seconds and 5 git commands to generate.