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

minium.ConditionalElements Maven / Gradle / Ivy

/*
 * Copyright (C) 2015 The Minium Authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package minium;

/**
 * Logic operations over elements. We consider a elements expression to evaluate
 * into a "true" value when its evaluated set is non-empty, and to be "false"
 * when it is empty.
 */
public interface ConditionalElements extends Elements {

    /**
     * Intersects both evaluated sets. For instance, if this
     * evaluates into { A, B, C } and elems evaluates
     * into { B, C, D }, then this.and(elems)
     * evaluates into { B, C }
     *
     * @param elems
     *            elements to intersect with
     * @return new {@link Elements} that corresponds to the intersection of
     *         this and elems
     */
    public abstract T and(Elements elems);

    /**
     * Represents the union both evaluated sets. For instance, if
     * this evaluates into { A, B, C } and
     * elems evaluates into { B, C, D }, then
     * this.or(elems) evaluates into { A, B, C, D }
     *
     * @param elems
     *            elements to union with
     * @return new {@link Elements} that corresponds to the union of
     *         this and elems
     */
    public abstract T or(Elements elems);

    /**
     * Evaluates into elems if and only if this
     * evaluates into a non-empty set, otherwise returns an empty set.
     * 

* For instance, if this evaluates into { A, B } * and elems evaluates into { B, C } then * this.then(elems) evaluates into { B, C }. *

* If this evaluates into an empty set, then * this.then(elems) evaluates into an empty set. * * @param elems * elements to evaluate into if this is non-empty * @return new {@link Elements} that evaluates into elems only * and only if this evaluates into a non-empty set, * otherwise returns an empty set. */ public abstract T then(Elements elems); /** * Evaluates into this if and only if elems * evaluates into a non-empty set, otherwise returns an empty set. * Basically, someElems.when(otherElems) is equivalent to * otherElems.then(someElems). * * @param elems * if non-empty, causes method to evaluate into this * @return new {@link Elements} that evaluates into this only * and only if elems evaluates into a non-empty set, * otherwise returns an empty set. */ public abstract T when(Elements elems); /** * Evaluates into this if and only if elems * evaluates into a empty set, otherwise returns an empty set. *

* For instance, if this evaluates into { A, B } * and elems evaluates into { B, C } then * this.unless(elems) evaluates into an empty set. *

* If elems evaluates into an empty set, then * this.unless(elems) evaluates into { A, B }. * * @param elems * if empty, causes method to evaluate into this * @return new {@link Elements} that evaluates into this only * and only if elems evaluates into a empty set, * otherwise returns an empty set. */ public abstract T unless(Elements elems); }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy