001/**
002 * Copyright 2005-2016 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.rice.krms.api.repository.operator;
017
018import org.kuali.rice.core.api.uif.RemotableAttributeError;
019import org.kuali.rice.krms.api.repository.function.FunctionDefinition;
020
021import java.util.List;
022
023/**
024 * A service that can export a custom function as an operator in the KRMS rule editor user interface.
025 *
026 * @author Kuali Rice Team (rice.collab@kuali.org)
027 */
028public interface CustomOperator {
029
030    /**
031     * gets the {@link org.kuali.rice.krms.api.repository.function.FunctionDefinition} for the function that will be
032     * evaluated at rule execution time.  Note that the backing FunctionTypeService must be locally available to the
033     * application at execution time, as execution objects in KRMS can not be obtained over the service bus.
034     *
035     * The FunctionDefinition returned by this method must have a return type of java.lang.Boolean, and must have
036     * either one or two FunctionParameterDefinitions.
037     *
038     * @return a FunctionDefinition with a return type of Boolean
039     */
040    FunctionDefinition getOperatorFunctionDefinition();
041
042    /**
043     * Validates that the given operand classes are acceptable for the custom function.
044     *
045     * <p>Note that the attribute name in returned errors will be ignored.</p>
046     * <p>If only a single operand has been specified, then rhsClassName will be null.</p>
047     *
048     * @param lhsClassName the class name for the left hand side operand
049     * @param rhsClassName the class name for the right hand side operand
050     * @return A list of errors, or an empty list if no errors are found
051     */
052    List<RemotableAttributeError> validateOperandClasses(String lhsClassName, String rhsClassName);
053}