/*
 * (c) Copyright Christian P. Fries, Germany. Contact: email@christian-fries.de.
 *
 * Created on 10.02.2004
 */
package net.finmath.montecarlo.interestrate.products;

import java.util.HashMap;
import java.util.Map;

import net.finmath.exception.CalculationException;
import net.finmath.montecarlo.AbstractMonteCarloProduct;
import net.finmath.montecarlo.MonteCarloSimulationModel;
import net.finmath.montecarlo.interestrate.LIBORModelMonteCarloSimulationModel;
import net.finmath.montecarlo.process.component.factordrift.FactorDriftInterface;
import net.finmath.stochastic.RandomVariable;

/**
 * Base class for products requiring an LIBORModelMonteCarloSimulationModel as base class
 *
 * @author Christian Fries
 * @version 1.0
 */
public abstract class AbstractLIBORMonteCarloProduct extends AbstractMonteCarloProduct implements TermStructureMonteCarloProduct {

	/**
	 * @param currency The currency of this product (may be null for "any currency").
	 */
	public AbstractLIBORMonteCarloProduct(String currency) {
		super(currency);
	}

	/**
	 *
	 */
	public AbstractLIBORMonteCarloProduct() {
		super(null);
	}

	/* (non-Javadoc)
	 * @see net.finmath.montecarlo.interestrate.products.TermStructureMonteCarloProduct#getValue(double, net.finmath.montecarlo.interestrate.LIBORModelMonteCarloSimulationModel)
	 */
	@Override
	public abstract RandomVariable getValue(double evaluationTime, LIBORModelMonteCarloSimulationModel model) throws CalculationException;

	public RandomVariable getValueForModifiedData(double evaluationTime, MonteCarloSimulationModel monteCarloSimulationModel, Map<String, Object> dataModified) throws CalculationException
	{
		return this.getValue(evaluationTime, monteCarloSimulationModel.getCloneWithModifiedData(dataModified));
	}

	/* (non-Javadoc)
	 * @see net.finmath.montecarlo.interestrate.products.TermStructureMonteCarloProduct#getValues(double, net.finmath.montecarlo.interestrate.LIBORModelMonteCarloSimulationModel)
	 */
	@Override
	public Map<String, Object> getValues(double evaluationTime, LIBORModelMonteCarloSimulationModel model) throws CalculationException {
		RandomVariable value = getValue(evaluationTime, model);
		Map<String, Object> result = new HashMap<>();
		result.put("value", value.getAverage());
		result.put("error", value.getStandardError());
		return result;
	}

	@Override
	public RandomVariable getValue(double evaluationTime, MonteCarloSimulationModel model) throws CalculationException {
		// This product requires an LIBORModelMonteCarloSimulationModel model, otherwise there will be a class cast exception
		if(model instanceof LIBORModelMonteCarloSimulationModel) {
			return getValue(evaluationTime, (LIBORModelMonteCarloSimulationModel)model);
		}
		else {
			throw new IllegalArgumentException("The product " + this.getClass()
			+ " cannot be valued against a model " + model.getClass() + "."
			+ "It requires a model of type " + LIBORModelMonteCarloSimulationModel.class + ".");
		}
	}

	/* (non-Javadoc)
	 * @see net.finmath.montecarlo.interestrate.products.TermStructureMonteCarloProduct#getFactorDrift(net.finmath.montecarlo.interestrate.LIBORModelMonteCarloSimulationModel, net.finmath.montecarlo.interestrate.LIBORModelMonteCarloSimulationModel)
	 */
	@Override
	public FactorDriftInterface getFactorDrift(LIBORModelMonteCarloSimulationModel referenceScheme, LIBORModelMonteCarloSimulationModel targetScheme) {
		return null;
	}
}

@@ -1117,206 +1117,8 @@
 %09%7D%0A%0A
-%09/* (non-Javadoc)%0A%09 * @see net.finmath.montecarlo.interestrate.products.TermStructureMonteCarloProduct#getValue(double, net.finmath.montecarlo.interestrate.LIBORModelMonteCarloSimulationModel)%0A%09 */%0A
 %09@Ov
@@ -1116,32 +1116,32 @@
 %0A%09%7D%0A%0A%09@Override%0A
+
 %09public abstract
@@ -1563,207 +1563,8 @@
 %09%7D%0A%0A
-%09/* (non-Javadoc)%0A%09 * @see net.finmath.montecarlo.interestrate.products.TermStructureMonteCarloProduct#getValues(double, net.finmath.montecarlo.interestrate.LIBORModelMonteCarloSimulationModel)%0A%09 */%0A
 %09@Ov
@@ -2564,277 +2564,8 @@
 %09%7D%0A%0A
-%09/* (non-Javadoc)%0A%09 * @see net.finmath.montecarlo.interestrate.products.TermStructureMonteCarloProduct#getFactorDrift(net.finmath.montecarlo.interestrate.LIBORModelMonteCarloSimulationModel, net.finmath.montecarlo.interestrate.LIBORModelMonteCarloSimulationModel)%0A%09 */%0A
 %09@Ov
@@ -2726,19 +2726,74 @@
 %7B%0A%09%09
-return null
+throw new UnsupportedOperationException(%22Method not implemented.%22)
 ;%0A%09%7D

Clean up.