/*
 * Copyright (c) 2014-2016 Manuel Mauky
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package eu.lestard.advanced_bindings.api;

import javafx.beans.binding.Bindings;
import javafx.beans.binding.BooleanBinding;
import javafx.beans.value.ObservableValue;

import java.util.Arrays;


public class LogicBindings {

    /**
     * A boolean binding that is `true` only when all dependent observable boolean values
     * are `true`.
     *
     * This can be useful in cases where the
     * {@link Bindings#and(javafx.beans.value.ObservableBooleanValue, javafx.beans.value.ObservableBooleanValue)}
     * with 2 arguments isn't enough.
     *
     * @param values variable number of observable boolean values that are used for the binding
     * @return the boolean binding
     */
    @SafeVarargs
    public static BooleanBinding and(ObservableValue<Boolean>...values) {
        return Bindings.createBooleanBinding(
            ()-> !Arrays.stream(values)
                .filter(observable -> !observable.getValue())
                .findAny()
                .isPresent(), values);
    }

    /**
     * A boolean binding that is only `true` when at leased one of the dependent observable boolean values
     * are `true`.
     *
     * This can be useful in cases where the
     * {@link Bindings#or(javafx.beans.value.ObservableBooleanValue, javafx.beans.value.ObservableBooleanValue)}
     * with 2 arguments isn't enough.
     *
     * @param values variable number of observable boolean values that are used for the binding
     * @return the boolean binding
     */
    @SafeVarargs
    public static BooleanBinding or(ObservableValue<Boolean>...values) {
        return Bindings.createBooleanBinding(()-> Arrays.stream(values)
            .filter(ObservableValue::getValue)
            .findAny()
            .isPresent(), values);
    }
}

@@ -1309,16 +1309,45 @@
 Arrays;%0A
+import java.util.Collection;%0A
 %0A%0Apublic
@@ -2149,16 +2149,664 @@
 %0A    %7D%0A%0A
+    /**%0A     * A boolean binding that is %60true%60 only when all dependent observable boolean values%0A     * are %60true%60.%0A     *%0A     * This can be useful in cases where the%0A     * %7B@link Bindings#and(javafx.beans.value.ObservableBooleanValue, javafx.beans.value.ObservableBooleanValue)%7D%0A     * with 2 arguments isn't enough.%0A     *%0A     * @param values collection of observable boolean values that are used for the binding%0A     * @return the boolean binding%0A     */%0A    @SuppressWarnings(%22unchecked%22)%0A    public static BooleanBinding and(Collection%3CObservableValue%3CBoolean%3E%3E values) %7B%0A        return and(values.toArray(new ObservableValue%5B0%5D));%0A    %7D%0A%0A
     /**%0A
@@ -3504,32 +3504,32 @@
      .findAny()%0A
-
             .isP
@@ -3552,11 +3552,673 @@
 );%0A    %7D
+%0A%0A    /**%0A     * A boolean binding that is only %60true%60 when at leased one of the dependent observable boolean values%0A     * are %60true%60.%0A     *%0A     * This can be useful in cases where the%0A     * %7B@link Bindings#or(javafx.beans.value.ObservableBooleanValue, javafx.beans.value.ObservableBooleanValue)%7D%0A     * with 2 arguments isn't enough.%0A     *%0A     * @param values collection of observable boolean values that are used for the binding%0A     * @return the boolean binding%0A     */%0A    @SuppressWarnings(%22unchecked%22)%0A    public static BooleanBinding or(Collection%3CObservableValue%3CBoolean%3E%3E values) %7B%0A        return or(values.toArray(new ObservableValue%5B0%5D));%0A    %7D
 %0A%7D%0A

Add Collection overloads to LogicBindings