![JAR search and dependency download from the Maven repository](/logo.png)
fr.landel.utils.assertor.predicate.OperatorNand Maven / Gradle / Ivy
/*-
* #%L
* utils-assertor
* %%
* Copyright (C) 2016 - 2018 Gilles Landel
* %%
* 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.
* #L%
*/
package fr.landel.utils.assertor.predicate;
import fr.landel.utils.assertor.StepAssertor;
import fr.landel.utils.assertor.enums.EnumOperator;
import fr.landel.utils.assertor.helper.HelperStep;
/**
* This class is an intermediate link in Assertor chain, see
* {@link PredicateAssertorStep}.
*
* @since Mar 28, 2017
* @author Gilles
*
* @param
* the type of predicate step
* @param
* the type of checked object
*/
public interface OperatorNand, T> {
/**
* @return the step result
*/
StepAssertor getStep();
/**
* The only purpose is to avoid the copy of basic methods into children
* interfaces. This is an indirect way to create specific
* {@link PredicateStep} by overriding this interface. All children class
* has to override this method
*
* @param result
* the result
* @return the predicate step
*/
S get(StepAssertor result);
/**
* Applies a predicate step in the current one with the operator
* {@link EnumOperator#NAND}. The aim of this is to provide the equivalence
* of parenthesis in condition expressions.
*
*
* // '' empty nand 'text' not empty and contains 'r'
* Assertor.that("").isEmpty().nand("text").isNotEmpty().and().contains("r").isOK();
* // -> false (because: true nand true and false => true nand true = false
* // => false and false = false)
*
* // '' empty nand ('text' not empty and contains 'r')
* Assertor.that("text").isEmpty().nand(Assertor.that("text").isEmpty().nand().contains("r")).isOK();
* // -> true (because: false nand false => (false nand false) = true)
*
*
* @param other
* the other predicate step
* @return this predicate step with the other injected
*/
default S nand(final PredicateStep other) {
return this.get(HelperStep.nand(this.getStep(), other.getStep()));
}
/**
* Append an operator '{@link EnumOperator#NAND}' on the current step.
*
* @return the predicate assertor
*/
default PredicateAssertorStep nand() {
return () -> HelperStep.nand(this.getStep());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy