title: How can I prevent some code duplication for a feed handler
body: <p>I have a feed handler and I would like to prevent the data handle again if the value updated is same as previous value, so I have code like this</p>
  
  <pre><code>map.get(statisticsOpenAcronym).map { x =&gt;
    var open = x.asInstanceOf[Number].doubleValue();
    if (statistics.open != open) {
      statistics.open = open;
      statistics.changed = true;
    }
  }
  map.get(statisticsCloseAcronym).map { x =&gt;
    var close = x.asInstanceOf[Number].doubleValue();
    if (statistics.close != close) {
      statistics.close = close;
      statistics.changed = true;
    }
  }
  </code></pre>
  
  <p>But then I need to have the [if xxx is difference, the update xxx and set change flag ] replicate again and again.</p>
  
  <p>Just wonder, how can I prevent this?</p>