Java Collection Empty isNullOrEmpty(Collection s)

Here you can find the source of isNullOrEmpty(Collection s)

Description

is Null Or Empty

License

Open Source License

Declaration

public static boolean isNullOrEmpty(Collection<?> s) 

Method Source Code

//package com.java2s;

import java.util.*;

public class Main {
    public static boolean isNullOrEmpty(Object s) {
        if (s == null) {
            return true;
        }//from   w  w  w.  j  a v a2 s.  co m
        if (s.getClass().isArray()) {
            return isNullOrEmpty((Object[]) s);
        }
        if (s instanceof String) {
            return isNullOrEmpty((String) s);
        }
        if (s instanceof Collection) {
            return isNullOrEmpty((Collection<?>) s);
        }
        if (s instanceof Map) {
            return isNullOrEmpty((Map<?, ?>) s);
        }
        return false;
    }

    public static boolean isNullOrEmpty(String s) {
        return (s == null || s.isEmpty() || s.trim().toLowerCase()
                .equals("null"));
    }

    public static boolean isNullOrEmpty(Object[] s) {
        return (s == null || s.length == 0);
    }

    public static boolean isNullOrEmpty(Collection<?> s) {
        return (s == null || s.isEmpty());
    }

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

Related

  1. isNullOrEmpty(Collection collection)
  2. isNullOrEmpty(Collection col)
  3. isNullOrEmpty(Collection collection)
  4. isNullOrEmpty(Collection list)
  5. isNullOrEmpty(Collection obj)
  6. isNullOrEmpty(Collection values)
  7. isNullOrEmpty(final Collection c)
  8. isNullOrEmpty(final Collection collection)
  9. isNullOrEmpty(final Collection value)