title: Converting angular2-query-builder query to logical expression
body: <p>I use <a href="https://www.npmjs.com/package/angular2-query-builder" rel="nofollow noreferrer">angular2-query-builder</a> in my project. Besides, the back-end project using Java, Spring boot and Rulebook as a rule engine in order to fire rules which are generated by angular2-query-builder. So I need to make a logical expression from the output of angular2-query-builder.</p>
  
  <p>This is a type-script object generated by query-builder.</p>
  
  <pre><code>  query = {
      condition: 'and',
      rules: [
        {field: 'age', operator: '&lt;=', value: '16'},
        {field: 'gender', operator: '=', value: 'm'}
      ]
    };
  </code></pre>
  
  <p>The mapped model class which I've made in the back-end :</p>
  
  <pre><code>RuleSet {
      String field;
      String value;
      String operator;
      String entity;
      String condition;
      RuleSet[] rules;
  //...getters and setters}
  </code></pre>
  
  <p>I need to get <code>(age &lt;= 16) &amp;&amp; (gender = 'm')</code> from the object.</p>