Java Array Value Any anyNotNull(Object... tests)

Here you can find the source of anyNotNull(Object... tests)

Description

Returns true if any value in the passed array is non-null

License

Open Source License

Declaration

public static boolean anyNotNull(Object... tests) 

Method Source Code

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

public class Main {
    /**/*from  ww  w  .  j av a  2  s  . c  o m*/
     * Returns true if any value in the passed array is non-null
     */
    public static boolean anyNotNull(Object... tests) {
        return coalesce(tests) != null;
    }

    /**
     * Returns the first non-null value in the passed array
     */
    public static <T extends Object> T coalesce(T... tests) {
        if (tests != null) {
            for (int i = 0; i < tests.length; i++) {
                if (notNull(tests[i])) {
                    return tests[i];
                }
            }
        }
        return null;
    }

    /**
     * Returns true if object is not null and not empty string
     */
    public static boolean notNull(Object o) {
        return !isNull(o);
    }

    /**
     * Returns true if object is null or empty String
     */
    public static boolean isNull(Object o) {
        return o == null || o.equals("");
    }
}

Related

  1. anyInstance(Throwable t, Class[] types)
  2. anyIsTrue(Boolean... conditions)
  3. anyMore(int[] target, int[] test)
  4. anyNoneNull(String... arrays)
  5. anyNotNull(final Object... values)
  6. anyNull(Object... args)
  7. anyNull(Object... args)
  8. anyNull(Object... objects)
  9. anyNull(Object... objs)