to top
public class

NullUtil

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

Class Overview

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.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public NullUtil ()

Public Methods

public static 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.

public static int countNonNulls (Object... objs)

Counts non-null objects in the passed set

Parameters
objs Object
Returns
int

public static int countNulls (Object... objs)

Counts null objects in the passed set

Parameters
objs Object
Returns
int

public static 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.

public static 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.