Here you can find the source of nvl(Integer value, Number valueWhenNull)
nvl
function of Oracle SQL.
Parameter | Description |
---|---|
value | a parameter |
valueWhenNull | a parameter |
null
, otherwise valueWhenNull
public static int nvl(Integer value, Number valueWhenNull)
//package com.java2s; /******************************************************************************* * Copyright (c) 2010-2015 BSI Business Systems Integration AG. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors:/*w ww . j a va 2s.c om*/ * BSI Business Systems Integration AG - initial API and implementation ******************************************************************************/ public class Main { /** * Imitates the <code>nvl</code> function of Oracle SQL. * * @param value * @param valueWhenNull * @return value if value is not <code>null</code>, otherwise valueWhenNull. */ public static <T> T nvl(T value, T valueWhenNull) { if (value != null) { return value; } else { return valueWhenNull; } } /** * Imitates the <code>nvl</code> function of Oracle SQL. * * @param value * @param valueWhenNull * @return value if value is not <code>null</code>, otherwise valueWhenNull */ public static int nvl(Integer value, Number valueWhenNull) { if (value != null) { return value; } else { return valueWhenNull.intValue(); } } /** * Imitates the <code>nvl</code> function of Oracle SQL. * * @param value * @param valueWhenNull * @return value if value is not <code>null</code>, otherwise valueWhenNull */ public static long nvl(Long value, Number valueWhenNull) { if (value != null) { return value; } else { return valueWhenNull.longValue(); } } }