/*
Copyright (C) 2007 Richard Gomes
This source code is release under the BSD License.
This file is part of JQuantLib, a free-software/open-source library
for financial quantitative analysts and developers - http://jquantlib.org/
JQuantLib is free software: you can redistribute it and/or modify it
under the terms of the JQuantLib license. You should have received a
copy of the license along with this program; if not, please email
. The license is also available online at
.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the license for more details.
JQuantLib is based on QuantLib. http://quantlib.org/
When applicable, the original copyright notice follows this notice.
*/
/*
Copyright (C) 2003, 2006 Ferdinando Ametrano
Copyright (C) 2006 StatPro Italia srl
This file is part of QuantLib, a free-software/open-source library
for financial quantitative analysts and developers - http://quantlib.org/
QuantLib is free software: you can redistribute it and/or modify it
under the terms of the QuantLib license. You should have received a
copy of the license along with this program; if not, please email
. The license is also available online at
.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the license for more details.
*/
package org.jquantlib.instruments;
import org.jquantlib.lang.exceptions.LibraryException;
import org.jquantlib.util.PolymorphicVisitable;
import org.jquantlib.util.PolymorphicVisitor;
import org.jquantlib.util.Visitor;
/**
* Abstract base class for option payoffs
*
* @author Richard Gomes
*/
public abstract class Payoff implements PolymorphicVisitable {
//
// protected static final
//
/**
* This protected constant is declared for convenience of extended classes
*/
protected static final String UNKNOWN_OPTION_TYPE = "unknown option type";
//
// public abstract methods
//
/**
* @warning This method is used for output and comparison between payoffs.
* It is not meant to be used for writing switch-on-type code.
*/
public abstract String name() /* @ReadOnly */ ;
public abstract String description() /* @ReadOnly */ ;
/**
* Returns the value of an {@link Instrument} at maturity under {@link Payoff} conditions
*/
public abstract double get(double price) /* @ReadOnly */;
//
// overrides Object
//
@Override
public String toString() {
return description();
}
//
// implements PolymorphicVisitable
//
@Override
public void accept(final PolymorphicVisitor pv) {
final Visitor v = (pv!=null) ? pv.visitor(this.getClass()) : null;
if (v != null) {
v.visit(this);
} else {
throw new LibraryException("null payoff visitor"); // TODO: message
}
}
}
Ads help maintain this website.