All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.swiftboot.util.BooleanUtils Maven / Gradle / Ivy

The newest version!
package org.swiftboot.util;

import java.util.List;

/**
 * @author swiftech
 * @since 2.0.2
 */
public class BooleanUtils {

    /**
     * Performs an 'or' operation on a set of booleans.
     * Null in the list will be ignored
     *
     * @param list
     * @return
     */
    public static Boolean or(List list) {
        Boolean ret = null;
        for (final Boolean element : list) {
            if (element != null) {
                if (element) {
                    return Boolean.TRUE;
                }
                else {
                    ret = Boolean.FALSE;
                }
            }
        }
        return ret;
    }

    /**
     * Performs an 'or' operation on a set of booleans.
     * Null in the array will be ignored
     *
     * @param array
     * @return
     */
    public static Boolean or(Boolean... array) {
        Boolean ret = null;
        for (final Boolean element : array) {
            if (element != null) {
                if (element) {
                    return Boolean.TRUE;
                }
                else {
                    ret = Boolean.FALSE;
                }
            }
        }
        return ret;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy