Java List Null Empty isNotNullAndEmpty(List list)

Here you can find the source of isNotNullAndEmpty(List list)

Description

is Not Null And Empty

License

Open Source License

Parameter

Parameter Description
dsToFree a parameter

Declaration

public static boolean isNotNullAndEmpty(List<?> list) 

Method Source Code

//package com.java2s;
/*/* ww  w.  j a  va 2  s .c o  m*/
 * Copyright 2012 The Solmix Project
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * http://www.gnu.org/licenses/ 
 * or see the FSF site: http://www.fsf.org. 
 */

import java.util.Collection;

import java.util.List;
import java.util.Map;

public class Main {
    static public boolean isNotNullAndEmpty(String str) {
        return !isNullOrEmpty(str);
    }

    static public boolean isNotNullAndEmpty(StringBuffer sb) {
        return !isNullOrEmpty(sb);
    }

    /**
     * @param dsToFree
     * @return
     */
    public static boolean isNotNullAndEmpty(List<?> list) {
        return list != null && list.size() > 0;
    }

    /**
     * @param <T>
     * @param filterProperties
     * @return
     */
    public static <T> boolean isNotNullAndEmpty(T[] filterProperties) {
        return filterProperties != null && filterProperties.length > 0;
    }

    /**
     * @param cmap
     * @return
     */
    public static boolean isNotNullAndEmpty(Map<?, ?> map) {
        return map != null && !map.isEmpty();
    }

    static public boolean isNullOrEmpty(String str) {
        return (str == null || str.trim().length() < 1);
    }

    /**
     * @param clause
     * @return
     */
    public static boolean isNullOrEmpty(StringBuffer sb) {

        return !(sb != null && sb.length() > 0);
    }

    /**
     * @param files
     * @return
     */
    public static boolean isNullOrEmpty(Collection<?> list) {
        return list == null || list.size() < 1;
    }

    public static <T> boolean isNullOrEmpty(T[] list) {
        return list == null || list.length < 1;
    }

    public static boolean isNullOrEmpty(Map<?, ?> map) {
        return map == null || map.isEmpty();
    }

    /**
     * <p>Checks if a String is empty ("") or null.</p>
     *
     * <pre>
     * DataUtils.isEmpty(null)      = true
     * DataUtils.isEmpty("")        = true
     * DataUtils.isEmpty(" ")       = false
     * DataUtils.isEmpty("bob")     = false
     * DataUtils.isEmpty("  bob  ") = false
     * </pre>
     *
     * <p>NOTE: This method changed in Lang version 2.0.
     * It no longer trims the String.
     * That functionality is available in isBlank().</p>
     */
    public static boolean isEmpty(String str) {
        return str == null || str.length() == 0;
    }
}

Related

  1. isNotEmpty(List value)
  2. isNotEmpty(List list)
  3. isNotEmpty(List list)
  4. isNotEmpty(List list)
  5. isNotEmpty(List objList)
  6. isNotNullAndNotEmpty(List list)
  7. isNull(List list)
  8. isNullish(java.util.List value)
  9. isNullList(List l)