001    /**
002     * Copyright 2007 Mike Kroutikov.
003     *
004     * This program is free software; you can redistribute it and/or modify
005     *   it under the terms of the Lesser GNU General Public License as 
006     *   published by the Free Software Foundation; either version 3 of
007     *   the License, or (at your option) any later version.
008     *
009     *   This program is distributed in the hope that it will be useful,
010     *   but WITHOUT ANY WARRANTY; without even the implied warranty of
011     *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012     *   Lesser GNU General Public License for more details.
013     *
014     *   You should have received a copy of the Lesser GNU General Public License
015     *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
016     */
017    
018    package org.otfeed.command;
019    
020    /**
021     * Composite, encapsulating a price range.
022     * Used as predicate when searching for options.
023     * </p>
024     * @see OptionChainCommand
025     * @see OptionChainSnapshotCommand
026     * @see OptionChainWithSnapshotCommand
027     */
028    public final class PriceRange {
029    
030            /**
031             * Lower boundary of the price range.
032             */
033            public final double min;
034    
035            /**
036             * Upper boundary of the price range.
037             */
038            public final double max;
039    
040            /**
041             * Constructs composite object.
042             */
043            public PriceRange(double min, double max) {
044    
045                    this.min = min;
046                    this.max = max;
047    
048                    if(min > max || min < 0.0) {
049                            throw new IllegalArgumentException(
050                                    "max must not be less than min, and min must not be negative");
051                    }
052            }
053    
054            @Override
055            public String toString() {
056                    return "PriceRange: min=" + min + ", max=" + max;
057            }
058    }