/**
 * Copyright (C) 2011 - present by OpenGamma Inc. and the OpenGamma group of companies
 * 
 * Please see distribution for license.
 */
package com.opengamma.engine.marketdata.availability;

import com.opengamma.engine.ComputationTargetType;
import com.opengamma.engine.marketdata.MarketDataSnapshot;
import com.opengamma.engine.marketdata.snapshot.UserMarketDataSnapshot;
import com.opengamma.engine.value.ValueRequirement;
import com.opengamma.engine.value.ValueRequirementNames;
import com.opengamma.util.ArgumentChecker;

/**
 * An implementation of {@link MarketDataAvailabilityProvider} which uses an underlying {@link MarketDataSnapshot} as  
 * the definition of whether a requirement can be satisfied.
 */
public class MarketDataSnapshotAvailabilityProvider implements MarketDataAvailabilityProvider {

  private final MarketDataSnapshot _snapshot;

  /**
   * Constructs an instance.
   * 
   * @param snapshot  the initialised snapshot, not null
   */
  public MarketDataSnapshotAvailabilityProvider(MarketDataSnapshot snapshot) {
    ArgumentChecker.notNull(snapshot, "snapshot");
    _snapshot = snapshot;
  }

  @Override
  public MarketDataAvailability getAvailability(final ValueRequirement requirement) {
    if (requirement.getTargetSpecification().getType() == ComputationTargetType.PORTFOLIO_NODE ||
        requirement.getTargetSpecification().getType() == ComputationTargetType.POSITION ||
        requirement.getTargetSpecification().getType() == ComputationTargetType.TRADE) {
      return MarketDataAvailability.NOT_AVAILABLE;
    }
    if (ValueRequirementNames.VOLATILITY_SURFACE_DATA.equals(requirement.getValueName())) {
      System.out.println();
    }
    if (getSnapshot().query(requirement) != null) {
      return MarketDataAvailability.AVAILABLE;
    }
    if (UserMarketDataSnapshot.getStructuredKey(requirement) != null) {
      return MarketDataAvailability.MISSING;
    }
    return MarketDataAvailability.NOT_AVAILABLE;
  }

  //-------------------------------------------------------------------------
  private MarketDataSnapshot getSnapshot() {
    return _snapshot;
  }

}

@@ -425,65 +425,8 @@
 nt;%0A
-import com.opengamma.engine.value.ValueRequirementNames;%0A
 impo
@@ -1501,134 +1501,8 @@
   %7D%0A
-    if (ValueRequirementNames.VOLATILITY_SURFACE_DATA.equals(requirement.getValueName())) %7B%0A      System.out.println();%0A    %7D%0A
     

Remove debug code accidentally checked in.