class ExpressionUtils {

    public static void populatePropertyExpressionsFromGraph(UifDictionaryBean expressionConfigurable) {
        if (expressionConfigurable == null || expressionConfigurable.getExpressionGraph() == null) {
            return;
        }

        // will hold graphs to populate the refreshExpressionGraph property on each expressionConfigurable
        // key is the path to the expressionConfigurable and value is the map of nested property names to expressions
        Map<String, Map<String, String>> refreshExpressionGraphs = new HashMap<String, Map<String, String>>();

        Map<String, String> expressionGraph = expressionConfigurable.getExpressionGraph();
        for (Map.Entry<String, String> expressionEntry : expressionGraph.entrySet()) {
            String propertyName = expressionEntry.getKey();
            String expression = expressionEntry.getValue();

            // by default assume expression belongs with passed in expressionConfigurable
            UifDictionaryBean configurableWithExpression = expressionConfigurable;

            // if property name is nested, we need to move the expression to the last expressionConfigurable
            String adjustedPropertyName = propertyName;
            if (StringUtils.contains(propertyName, ".")) {
                String configurablePath = StringUtils.substringBeforeLast(propertyName, ".");
                adjustedPropertyName = StringUtils.substringAfterLast(propertyName, ".");

                Object nestedObject = ObjectPropertyUtils.getPropertyValue(expressionConfigurable, configurablePath);

                // skip missing expression object for components skipping their lifecycle because objects
                // in these components may be missing (and are expected to be missing)
                if (nestedObject == null
                        && expressionConfigurable instanceof LifecycleElement
                        && ((LifecycleElement) expressionConfigurable).skipLifecycle()) {
                    continue;
                }

                if ((nestedObject == null) || !(nestedObject instanceof UifDictionaryBean)) {
                    throw new RiceRuntimeException("Object for which expression is configured on is null or does not "
                            + "implement UifDictionaryBean: '"
                            + configurablePath
                            + "' on class "
                            + expressionConfigurable.getClass().getName()
                            + " while evaluating "
                            + "expression for "
                            + propertyName);
                }

                // use nested object as the expressionConfigurable which will get the property expression
                configurableWithExpression = (UifDictionaryBean) nestedObject;
            }

            configurableWithExpression.getPropertyExpressions().put(adjustedPropertyName, expression);
        }
    }

}