Java Array Null Element isNull(T array[])

Here you can find the source of isNull(T array[])

Description

Array is empty

License

Open Source License

Parameter

Parameter Description
array a parameter

Declaration

public static <T> boolean isNull(T array[]) 

Method Source Code

//package com.java2s;
/*//from   w  ww.  j a  v a2 s.c o  m
 * Copyright (C) 2009-2015 SM2 SOFTWARE & SERVICES MANAGEMENT
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program has been created in the hope that it will be useful.
 * It is distributed WITHOUT ANY WARRANTY of any Kind,
 * without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see http://www.gnu.org/licenses/.
 *
 * For more information, please contact SM2 Software & Services Management.
 * Mail: info@talaia-openppm.com
 * Web: http://www.talaia-openppm.com
 *
 * Module: utils
 * File: ValidateUtil.java
 * Create User: javier.hernandez
 * Create Date: 06/03/2015 14:35:37
 */

import java.util.*;

public class Main {
    /**
     * Value is null, equals empty or "null" return True
     * @param value
     * @return
     */
    public static boolean isNull(String value) {

        boolean isNull = true;

        value = (value == null ? value : value.trim());

        if (value != null && !"".equals(value) && !"NULL".equals(value.toUpperCase())) {
            isNull = false;
        }

        return isNull;
    }

    /**
     * List is empty
     * @param list
     * @return
     */
    public static <T> boolean isNull(Collection<?> list) {

        return list == null || list.isEmpty();
    }

    /**
     * Array is empty
     * @param array
     * @return
     */
    public static <T> boolean isNull(T array[]) {

        return array == null || array.length == 0;
    }
}

Related

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