Java Object NVL nvl(T o, T replacement)

Here you can find the source of nvl(T o, T replacement)

Description

Returns the passed object, if not null, or replacement otherwise

License

Open Source License

Declaration

public static <T extends Object> T nvl(T o, T replacement) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*from  ww w. java  2  s  .  co  m*/
     * Returns the passed object, if not null, or replacement otherwise
     */
    public static <T extends Object> T nvl(T o, T replacement) {
        return (isNull(o) ? replacement : o);
    }

    /**
     * Returns true if object is null or empty String
     */
    public static boolean isNull(Object o) {
        return o == null || o.equals("");
    }
}

Related

  1. nvl(String value)
  2. nvl(String value, String defaultValue)
  3. NVL(String value, String replace)
  4. nvl(String x, String y)
  5. nvl(T mainValue, T... fallbackValues)
  6. nvl(T o, T valueIfNull)
  7. nvl(T object, T defaultValue)
  8. nvl(T s, T def)
  9. nvl(T t, String message)