Java Array Null Element isNull(Object[] objects)

Here you can find the source of isNull(Object[] objects)

Description

is Null

License

Open Source License

Declaration

public static boolean isNull(Object[] objects) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;
import java.util.List;

public class Main {

    public static boolean isNull(Object[] objects) {
        if (objects != null && objects.length > 0) {
            for (Object object : objects) {

                if (object instanceof String) {
                    if ((String) object == null || "".equals((String) object)
                            || "NULL".equals(((String) object).toUpperCase())) {
                        return true;
                    }//from   w w  w. j  av  a  2  s  . c o  m
                } else if (object instanceof Integer) {
                    if ((Integer) object == 0) {
                        return true;
                    }
                } else if (object instanceof Long) {
                    if ((Long) object == 0) {
                        return true;
                    }
                } else if (object instanceof Double) {
                    if ((Double) object == 0.0) {
                        return true;
                    }
                } else if (object instanceof String[]) {
                    if ((String[]) object == null || ((String[]) object).length <= 0) {
                        return true;
                    }
                } else if (object instanceof int[]) {
                    if ((int[]) object == null || ((int[]) object).length <= 0) {
                        return true;
                    }
                } else if (object instanceof List) {
                    if (object == null || ((ArrayList<?>) object).size() <= 0) {
                        return true;
                    }
                } else {
                    if (object == null) {
                        return true;
                    }
                }
            }
        }

        return false;
    }
}

Related

  1. isNull(final Object[] array)
  2. isNull(T array[])
  3. isNullArray(String[] array)