org.op4j.operators.qualities.ExecutableOperator Maven / Gradle / Ivy
/*
* =============================================================================
*
* Copyright (c) 2010, The OP4J team (http://www.op4j.org)
*
* 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 org.op4j.operators.qualities;
import org.op4j.functions.IFunction;
/**
*
* This interface contains methods for executing functions.
*
*
* @since 1.0
*
* @author Daniel Fernández
*
*/
public interface ExecutableOperator {
/**
*
* Executes the specified function on the target object, creating a new operator
* containing the result of the execution.
*
*
* This function must be able to take as input an object of type T (the current operator's
* target type) and will return an object of type X, which will be from then on the new
* operator's target type.
*
*
* @param the type of the result, and new type for the operator
* @param function the function to be executed
* @return an operator on the results of function execution
*/
public ExecutableOperator exec(final IFunction super T,X> function);
/**
*
* Executes a function in a way equivalent to {@link #exec(IFunction)} but only
* on selected elements, leaving all other elements untouched.
*
*
* @param function the function to be executed on the selected elements
* @return an operator on the results of function execution
*/
public ExecutableOperator execIfNotNull(final IFunction super T,? extends T> function);
/**
*
* Executes a function in a way equivalent to {@link #exec(IFunction)} but only
* on selected elements, leaving all other elements untouched.
*
*
* @param function the function to be executed on the selected elements
* @return an operator on the results of function execution
*/
public ExecutableOperator execIfNull(final IFunction super T,? extends T> function);
/**
*
* Executes a function in a way equivalent to {@link #exec(IFunction)} but only
* on selected elements, leaving all other elements untouched.
*
*
* @param eval the evaluation function used to select elements
* @param function the function to be executed on the selected elements
* @return an operator on the results of function execution
*/
public ExecutableOperator execIfTrue(final IFunction super T, Boolean> eval, final IFunction super T,? extends T> function);
/**
*
* Executes a function in a way equivalent to {@link #exec(IFunction)} but only
* on selected elements, leaving all other elements untouched.
*
*
* @param eval the evaluation function used to select elements
* @param function the function to be executed on the selected elements
* @return an operator on the results of function execution
*/
public ExecutableOperator execIfFalse(final IFunction super T, Boolean> eval, final IFunction super T,? extends T> function);
/**
*
* Executes a function in a way equivalent to {@link #exec(IFunction)} but only
* on selected elements, leaving all other elements untouched.
*
*
* @param the new type returned by the functions
* @param function the function to be executed on the selected elements
* @param elseFunction the function to be executed on the non-selected elements
* @return an operator on the results of function execution
*/
public ExecutableOperator execIfNotNull(final IFunction super T,X> function, final IFunction super T,X> elseFunction);
/**
*
* Executes a function in a way equivalent to {@link #exec(IFunction)} but only
* on selected elements, leaving all other elements untouched.
*
*
* @param the new type returned by the functions
* @param function the function to be executed on the selected elements
* @param elseFunction the function to be executed on the non-selected elements
* @return an operator on the results of function execution
*/
public ExecutableOperator execIfNull(final IFunction super T,X> function, final IFunction super T,X> elseFunction);
/**
*
* Executes a function in a way equivalent to {@link #exec(IFunction)} but only
* on selected elements, leaving all other elements untouched.
*
*
* @param the new type returned by the functions
* @param eval the evaluation function used to select elements
* @param function the function to be executed on the selected elements
* @param elseFunction the function to be executed on the non-selected elements
* @return an operator on the results of function execution
*/
public ExecutableOperator execIfTrue(final IFunction super T, Boolean> eval, final IFunction super T,X> function, final IFunction super T,X> elseFunction);
/**
*
* Executes a function in a way equivalent to {@link #exec(IFunction)} but only
* on selected elements, leaving all other elements untouched.
*
*
* @param the new type returned by the functions
* @param eval the evaluation function used to select elements
* @param function the function to be executed on the selected elements
* @param elseFunction the function to be executed on the non-selected elements
* @return an operator on the results of function execution
*/
public ExecutableOperator execIfFalse(final IFunction super T, Boolean> eval, final IFunction super T,X> function, final IFunction super T,X> elseFunction);
}