Here you can find the source of nvl(String pArg1, String pArg2)
Parameter | Description |
---|---|
pArg1 | a parameter |
pArg2 | a parameter |
public static String nvl(String pArg1, String pArg2)
//package com.java2s; //License from project: Open Source License public class Main { /**/* w ww . j a v a 2 s. co m*/ * Returns arg2 if arg1 is null or empty, or arg1 otherwise. * @param pArg1 * @param pArg2 * @return */ public static String nvl(String pArg1, String pArg2) { return !isNull(pArg1) ? pArg1 : pArg2; } /** * Returns arg2 if arg1 is null, or arg1 otherwise. * @param <T> * @param pArg1 * @param pArg2 * @return */ public static <T> T nvl(T pArg1, T pArg2) { return pArg1 != null ? pArg1 : pArg2; } /** * Tests if a string is null or empty. * @param pArg1 * @return True if null or empty. */ public static boolean isNull(String pArg1) { return "".equals(pArg1 == null ? "" : pArg1); } }