title: how to access map of custom objects in drools
body: <p>I have following Drools rules file to which I send  map filled with Custom objects(NodeElement), map is a global variable because it has to be accessed by all the rules, have another global variable errors, which is populated when rule fails. i have used eval and was able to execute it successfully. After doing some research, found out that eval has some performance issues?</p>
  
  <p>My questions are...</p>
  
  <p>1) is performance issues negligible?</p>
  
  <p>2) is using eval a good practice?</p>
  
  <p>3) if i have to rewrite these rules? which is the best way to do it?</p>
  
  <pre><code>import java.util.Map;
  import com.infodev.pojo.NodeElement;
  import com.main.Errors;
  import com.validation.DateValidation;
  
  global java.util.Map map;
  global com.main.Errors errors;
  
  
  rule "Fixed / Floating ccy rule"
  
      when
          eval(!((NodeElement)map.get("FixedCurrency")).getValue().equals(((NodeElement)map.get("FloatingCurrency")).getValue()))
      then 
          errors.addError( "Currency", "Fixed currency should be same as Floating currency" );
  end
  
  rule "Payment / Settlement date rule"
  
      when
          eval(!(DateValidation.paymentDateValidation(((NodeElement)map.get("tradeDate")).getValue(),((NodeElement)map.get("paymentDate")).getValue())))
  
      then 
          errors.addError(map.get("paymentDate").toString(), "Payment date should be after trade date" );
  
  end
  </code></pre>
  
  <p>And the map is:</p>
  
  <pre><code>Map&lt;String, NodeElement&gt; map = new HashMap&lt;String, NodeElement&gt;();
      map.put("FixedCurrency", new NodeElement("FixedCurrency", "USD"));
      map.put("FloatingCurrency", new NodeElement("FloatingCurrency", "UD"));
      map.put("tradeDate", new NodeElement("tradeDate", "2012-01-22"));
      map.put("paymentDate",new NodeElement("paymentDate", "2012-01-2"));
  </code></pre>