NullUtil

public class NullUtil
extends Object

java.lang.Object
   ↳ com.android.tradefed.util.NullUtil


A class with utility functions to help with dealing with null

Summary

Public constructors

NullUtil()

Public methods

static boolean allNull(Object... objs)

Checks if all objects are null.

static int countNonNulls(Object... objs)

Counts non-null objects in the passed set

static int countNulls(Object... objs)

Counts null objects in the passed set

static boolean isHomogeneousSet(Object... objs)

Check if every object is null, or every object is non-null.

static boolean singleNonNull(Object... objs)

Checks if exactly one object is non-null.

Public constructors

NullUtil

NullUtil ()

Public methods

allNull

boolean allNull (Object... objs)

Checks if all objects are null. Uses short-circuit logic, so may be more efficient than countNonNulls(Object) for sets of many objects.

Parameters
objs Object

Returns
boolean false if any passed objects are non-null. true otherwise. In particular, returns true of no objects are passed.

countNonNulls

int countNonNulls (Object... objs)

Counts non-null objects in the passed set

Parameters
objs Object

Returns
int

countNulls

int countNulls (Object... objs)

Counts null objects in the passed set

Parameters
objs Object

Returns
int

isHomogeneousSet

boolean isHomogeneousSet (Object... objs)

Check if every object is null, or every object is non-null. Uses short-circuit logic, so may be more efficient than countNulls(Object) and countNonNulls(Object) for sets of many objects.

Parameters
objs Object

Returns
boolean true if every object is null or if every object is non-null. false otherwise.

singleNonNull

boolean singleNonNull (Object... objs)

Checks if exactly one object is non-null. Uses short-circuit logic, so may be more efficient than countNonNulls(Object) for sets of many objects.

Parameters
objs Object

Returns
boolean true if there is exactly one non-null object in the list. false otherwise.