Example usage for org.apache.commons.lang3 ObjectUtils firstNonNull

List of usage examples for org.apache.commons.lang3 ObjectUtils firstNonNull

Introduction

In this page you can find the example usage for org.apache.commons.lang3 ObjectUtils firstNonNull.

Prototype

public static <T> T firstNonNull(final T... values) 

Source Link

Document

Returns the first value in the array which is not null .

Usage

From source file:io.github.rhkiswani.javaff.lang.utils.ArraysUtils.java

public static boolean isEmpty(Object[] arr) {
    if (arr == null) {
        return true;
    }/*from  w  ww  .j  a va 2 s .c om*/
    if (arr.length == 0) {
        return true;
    }
    if (arr.length >= MAX_ARRAY_SIZE) {
        throw new IllegalParamException(SmartException.EXCEEDS_LIMIT, "Array", 500000);
    }
    return ObjectUtils.firstNonNull(arr) == null;
}

From source file:org.apache.hadoop.hbase.client.AsyncRegionLocatorHelper.java

/**
 * Create a new {@link RegionLocations} based on the given {@code oldLocs}, and remove the
 * location for the given {@code replicaId}.
 * <p/>/*from   ww  w.j  a va 2 s .  c o  m*/
 * All the {@link RegionLocations} in async locator related class are immutable because we want to
 * access them concurrently, so here we need to create a new one, instead of calling
 * {@link RegionLocations#remove(int)}.
 */
static RegionLocations removeRegionLocation(RegionLocations oldLocs, int replicaId) {
    HRegionLocation[] locs = oldLocs.getRegionLocations();
    if (locs.length < replicaId + 1) {
        // Here we do not modify the oldLocs so it is safe to return it.
        return oldLocs;
    }
    locs = Arrays.copyOf(locs, locs.length);
    locs[replicaId] = null;
    if (ObjectUtils.firstNonNull(locs) != null) {
        return new RegionLocations(locs);
    } else {
        // if all the locations are null, just return null
        return null;
    }
}