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.

Returns
  • 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

public static int countNulls (Object... objs)

Counts null objects in the passed set

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.

Returns
  • 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.

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