class ExpressionUtils {

    public static Double evaluateToDouble( String expression, Map<String, Object> vars )
    {
        Object result = evaluate( expression, vars );

        if ( result == null )
        {
            throw new IllegalStateException( "Result must be not null" );
        }

        if ( !isNumeric( String.valueOf( result ) ) )
        {
            throw new IllegalStateException( "Result must be numeric: " + result + ", " + result.getClass() );
        }

        return Double.valueOf( String.valueOf( result ) );
    }

}