Package com.opengamma.engine.view.client.merging

Source Code of com.opengamma.engine.view.client.merging.ViewComputationResultModelMerger

/**
* Copyright (C) 2009 - present by OpenGamma Inc. and the OpenGamma group of companies
*
* Please see distribution for license.
*/
package com.opengamma.engine.view.client.merging;

import com.opengamma.engine.value.ComputedValue;
import com.opengamma.engine.view.ViewComputationResultModel;
import com.opengamma.engine.view.ViewResultModel;
import com.opengamma.engine.view.impl.InMemoryViewComputationResultModel;

/**
* Provides the ability to merge {@link ViewResultModel} instances.
*/
public class ViewComputationResultModelMerger {

  private InMemoryViewComputationResultModel _currentMergedResult;
 
  /**
   * Adds a new result.
   *
   * @param newResult  the new result to merge
   */
  public void merge(ViewComputationResultModel newResult) {
    if (_currentMergedResult == null) {
      // Start of a new result
      _currentMergedResult = new InMemoryViewComputationResultModel();
    }
    for (ComputedValue marketData : newResult.getAllMarketData()) {
      _currentMergedResult.addMarketData(marketData);
    }
    ViewResultModelMergeUtils.merge(newResult, _currentMergedResult);
  }

  /**
   * Retrieves the latest merged result.
   *
   * @return  the latest merged result
   */
  public ViewComputationResultModel getLatestResult() {
    return _currentMergedResult;
  }
 
}
TOP

Related Classes of com.opengamma.engine.view.client.merging.ViewComputationResultModelMerger

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.