Java Object NVL nvl(T mainValue, T... fallbackValues)

Here you can find the source of nvl(T mainValue, T... fallbackValues)

Description

Allows a list of values to be provided, the first non-null value in the list is returned as the result.

License

Apache License

Parameter

Parameter Description
T a parameter
mainValue a parameter
fallbackValues a parameter

Declaration

public static <T> T nvl(T mainValue, T... fallbackValues) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**/*from www . j a  va  2s . c  o  m*/
     * Allows a list of values to be provided, the first non-null value in the
     * list is returned as the result.
     * 
     * @param <T>
     * @param mainValue
     * @param fallbackValues
     * @return
     */
    public static <T> T nvl(T mainValue, T... fallbackValues) {
        T result = mainValue;
        int idx = 0;
        while (result == null && idx < fallbackValues.length) {
            result = fallbackValues[idx++];
        }
        return result;
    }
}

Related

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