001 /*
002 Copyright (C) 2008 Richard Gomes
003
004 This source code is release under the BSD License.
005
006 This file is part of JQuantLib, a free-software/open-source library
007 for financial quantitative analysts and developers - http://jquantlib.org/
008
009 JQuantLib is free software: you can redistribute it and/or modify it
010 under the terms of the JQuantLib license. You should have received a
011 copy of the license along with this program; if not, please email
012 <jquant-devel@lists.sourceforge.net>. The license is also available online at
013 <http://www.jquantlib.org/index.php/LICENSE.TXT>.
014
015 This program is distributed in the hope that it will be useful, but WITHOUT
016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
017 FOR A PARTICULAR PURPOSE. See the license for more details.
018
019 JQuantLib is based on QuantLib. http://quantlib.org/
020 When applicable, the original copyright notice follows this notice.
021 */
022
023 /*
024 Copyright (C) 2003, 2006 Ferdinando Ametrano
025 Copyright (C) 2006 Warren Chou
026 Copyright (C) 2006, 2008 StatPro Italia srl
027 Copyright (C) 2006 Chiara Fornarola
028
029 This file is part of QuantLib, a free-software/open-source library
030 for financial quantitative analysts and developers - http://quantlib.org/
031
032 QuantLib is free software: you can redistribute it and/or modify it
033 under the terms of the QuantLib license. You should have received a
034 copy of the license along with this program; if not, please email
035 <quantlib-dev@lists.sf.net>. The license is also available online at
036 <http://quantlib.org/license.shtml>.
037
038 This program is distributed in the hope that it will be useful, but WITHOUT
039 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
040 FOR A PARTICULAR PURPOSE. See the license for more details.
041 */
042
043 package org.jquantlib.instruments;
044
045 import org.jquantlib.lang.exceptions.LibraryException;
046 import org.jquantlib.util.TypedVisitor;
047 import org.jquantlib.util.Visitor;
048
049 /**
050 * Dummy payoff class.
051 *
052 * @author Richard Gomes
053 */
054 public class NullPayoff extends Payoff {
055
056 //
057 // overrides Payoff
058 //
059
060 @Override
061 public String name() /* @ReadOnly */ {
062 return "Null";
063 }
064
065 @Override
066 public String description() /* @ReadOnly */ {
067 return name();
068 }
069
070 @Override
071 public final double get(final double price) /* @ReadOnly */ {
072 throw new LibraryException("dummy payoff given");
073 }
074
075
076 //
077 // implements TypedVisitable
078 //
079
080 @Override
081 public void accept(final TypedVisitor<Payoff> v) {
082 final Visitor<Payoff> v1 = (v!=null) ? v.getVisitor(this.getClass()) : null;
083 if (v1 != null) {
084 v1.visit(this);
085 } else {
086 super.accept(v);
087 }
088 }
089
090 }