001/**
002 * Copyright 2005-2015 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.engine.expression;
017
018import org.kuali.rice.krms.api.KrmsConstants;
019import org.kuali.rice.krms.framework.engine.expression.EngineComparatorExtension;
020import org.kuali.rice.krms.framework.engine.expression.StringCoercionExtension;
021
022import javax.jws.WebMethod;
023import javax.jws.WebResult;
024import javax.jws.WebService;
025import javax.jws.soap.SOAPBinding;
026import java.util.List;
027
028/**
029 * Interface for registering {@link EngineComparatorExtension} for use as a
030 * {@link org.kuali.rice.krms.framework.engine.expression.ComparisonOperator} when comparing
031 * {@link org.kuali.rice.krms.framework.engine.Proposition} {@link Term}s
032 *
033 * @author Kuali Rice Team (rice.collab@kuali.org)
034 */
035@WebService(name = "comparisonOperatorService", targetNamespace = KrmsConstants.Namespaces.KRMS_NAMESPACE_2_0)
036@SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
037public interface ComparisonOperatorService extends StringCoercionExtension {
038
039    /**
040     * The {@link List} of {@link EngineComparatorExtension}s.
041     * @return List<EngineComparatorExtension> of configured {@link EngineComparatorExtension}s.
042     */
043    public List<EngineComparatorExtension> getOperators();
044
045    /**
046     * List<EngineComparatorExtension> to use.
047     * @param operators
048     */
049    public void setOperators(List<EngineComparatorExtension> operators);
050
051    @Override
052    @WebMethod(operationName = "canCoerce")
053    @WebResult(name = "coerced")
054    public boolean canCoerce(String type, String value);
055
056    @Override
057    @WebMethod(operationName = "coerce")
058    @WebResult(name = "coerced")
059    public Object coerce(String type, String value);
060
061    /**
062     * Returns the int result of a compare between the lhs and rhs objects.
063     * @param lhs left hand side object
064     * @param rhs right hand side object
065     * @return int result of compare between lhs and rhs objects
066     */
067    public int compare(Object lhs, Object rhs);
068
069    /**
070     * Does the service have an Extension that can compare the given objects?
071     *
072     * @param leftHandSide left hand side Object
073     * @param rightHandSide right hand side Object
074     * @return boolean true a configured {@link EngineComparatorExtension} can compare the lhs and rhs Objects.
075     */
076    public boolean canCompare(Object leftHandSide, Object rightHandSide);
077
078    /**
079     * {@link EngineComparatorExtension} that canCompare the given Objects
080     * @param leftHandSide left hand side Object
081     * @param rightHandSide right hand side Object
082     * @return the EngineComparatorExtension that can compare the given Objects.
083     */
084    public EngineComparatorExtension findComparatorExtension(Object leftHandSide, Object rightHandSide);
085
086    /**
087     *
088     * @return List<StringCoercionExtension>
089     */
090    // this would move to a StringCoercionExtensionService if we go that way
091    public List<StringCoercionExtension> getStringCoercionExtensions();
092
093    /**
094     * The {@link List} of {@link StringCoercionExtension}s.
095     * @param stringCoercionExtensions
096     */
097    // this would move to a StringCoercionExtensionService if we go that way
098    public void setStringCoercionExtensions(List<StringCoercionExtension> stringCoercionExtensions);
099
100    /**
101     *
102     * @param type to coerce
103     * @param value to coerce
104     * @return {@link StringCoercionExtension} that can coerce the given type and value
105     */
106    // this would move to a StringCoercionExtensionService if we go that way
107    StringCoercionExtension findStringCoercionExtension(String type, String value);
108
109}