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.core.api.parameter; 017 018import java.io.Serializable; 019 020/** 021 * This is a stateful wrapper for Parameters, which provides convenient methods to evaluate a constrained value against a Parameter. 022 */ 023public interface ParameterEvaluator extends Serializable { 024 /** 025 * This method determines whether the constrainedValue specified when the ParameterEvaluator was created matches the parameter. 026 * 027 * @return boolean indicating whether the constrained value adheres to the restriction specified by the combination of the 028 * parameter constraint and the parameter value 029 */ 030 public boolean evaluationSucceeds(); 031 032 /** 033 * This method uses the evaluateAndAddError method. It passes the constrainedPropertyName as both the constrainedPropertyName 034 * and the userEditablePropertyName, i.e. it should be used when they are one and the same. 035 * 036 * @param businessObjectOrDocumentClass 037 * @param constrainedPropertyName 038 * @return boolean indicating whether evaluation succeeded (see evaluationSucceeds) 039 */ 040 public boolean evaluateAndAddError(Class<? extends Object> businessObjectOrDocumentClass, String constrainedPropertyName); 041 042 /** 043 * This method uses the evaluationSucceeds method to evaluate the constrainedValue. If evaluation does not succeed, it adds an 044 * error for the user. The businessObjectOrDocumentClass, nameOfConstrainedProperty and userEditablePropertyName are used by 045 * ParameterEvaluatorImpl to retrieve user friendly labels for the error message. The constrainedPropertyName corresponds to the 046 * field that has the value that the parameter is evaluating. The userEditablePropertyName corresponds to the field that has the 047 * value the user needs to correct to resolve the error. For example, the object type may be invalid, but the user needs to 048 * change the object code in order to remedy that. 049 * 050 * @param businessObjectOrDocumentClass 051 * @param userEditableFieldToHighlight 052 * @param nameOfconstrainedProperty 053 * @return boolean indicating whether evaluation succeeded (see evaluationSucceeds) 054 */ 055 public boolean evaluateAndAddError(Class<? extends Object> businessObjectOrDocumentClass, String constrainedPropertyName, String userEditablePropertyName); 056 057 /** 058 * This method determines whether the parameter lists allowed values or denied values. 059 * 060 * @return boolean indicating whether the parameter lists allowed values 061 */ 062 public boolean constraintIsAllow(); 063 064 /** 065 * This method creates a pretty String representation of parameter values for the user messages. 066 * 067 * @return user-friendly String representation of Parameter values 068 */ 069 public String getParameterValuesForMessage(); 070 071 /** 072 * This method returns the value of the correspnding Parameter. 073 * 074 * @return String value of underlying Parameter 075 */ 076 public String getValue(); 077}