org.broadleafcommerce.common.rule
Class MvelHelper

java.lang.Object
  extended by org.broadleafcommerce.common.rule.MvelHelper

public class MvelHelper
extends Object

Helper class for some common rule functions that can be called from mvel as well as utility functions to make calling MVEL rules within Broadleaf easier. An instance of this class is available to the mvel runtime under the variable name MvelHelper with the following functions: convertField(type, fieldValue) toUpperCase(value)

Author:
Jeff Fischer

Constructor Summary
MvelHelper()
           
 
Method Summary
static Object convertField(String type, String fieldValue)
          Converts a field to the specified type.
static boolean evaluateRule(String rule, Map<String,Object> ruleParameters)
          Returns true if the passed in rule passes based on the passed in ruleParameters.
static boolean evaluateRule(String rule, Map<String,Object> ruleParameters, Map expressionCache)
          Evaluates the passed in rule given the passed in parameters.
static Object toUpperCase(String value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MvelHelper

public MvelHelper()
Method Detail

convertField

public static Object convertField(String type,
                                  String fieldValue)
Converts a field to the specified type. Useful when

Parameters:
type -
fieldValue -
Returns:

toUpperCase

public static Object toUpperCase(String value)

evaluateRule

public static boolean evaluateRule(String rule,
                                   Map<String,Object> ruleParameters)
Returns true if the passed in rule passes based on the passed in ruleParameters. Also returns true if the rule is blank or null. Calls the evaluateRule(String, Map, Map) method passing in the DEFAULT_EXPRESSION_CACHE. For systems that need to cache a large number of rule expressions, an alternate cache can be passed in. The default cache is able to cache up to 1,000 rule expressions which should suffice for most systems.

Parameters:
rule -
ruleParameters -
Returns:

evaluateRule

public static boolean evaluateRule(String rule,
                                   Map<String,Object> ruleParameters,
                                   Map expressionCache)
Evaluates the passed in rule given the passed in parameters.

Parameters:
rule -
ruleParameters -
Returns:


Copyright © 2013. All Rights Reserved.