001    /*
002     * Copyright (c) 2005 Einar Pehrson <einar@pehrson.nu>.
003     *
004     * This file is part of
005     * CleanSheets - a spreadsheet application for the Java platform.
006     *
007     * CleanSheets is free software; you can redistribute it and/or modify
008     * it under the terms of the GNU General Public License as published by
009     * the Free Software Foundation; either version 2 of the License, or
010     * (at your option) any later version.
011     *
012     * CleanSheets is distributed in the hope that it will be useful,
013     * but WITHOUT ANY WARRANTY; without even the implied warranty of
014     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
015     * GNU General Public License for more details.
016     *
017     * You should have received a copy of the GNU General Public License
018     * along with CleanSheets; if not, write to the Free Software
019     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
020     */
021    package csheets.core.formula;
022    
023    import java.io.Serializable;
024    
025    import csheets.core.Value;
026    
027    /**
028     * A parameter of a function, i.e. the definition of a valid argument.
029     * @author Einar Pehrson
030     */
031    public class FunctionParameter implements Serializable {
032    
033            /** The unique version identifier used for serialization */
034            private static final long serialVersionUID = 1765109547537919342L;
035    
036            /** The value type of the argument */
037            private Value.Type valueType;
038    
039            /** The name of the argument */
040            private String name;
041    
042            /** Whether the parameter is optional */
043            private boolean optional;
044    
045            /** The description of the argument */
046            private String description;
047    
048            /**
049             * Creates a new function parameter.
050             * @param name the name of the argument
051             * @param optional whether the parameter is optional
052             * @param description the description of the argument
053             */
054            public FunctionParameter(Value.Type valueType, String name,
055                            boolean optional, String description) {
056                    this.valueType = valueType;
057                    this.name = name;
058                    this.optional = optional;
059                    this.description = description;
060            }
061    
062            /**
063             * Returns the value type of the argument.
064             * @return the value type of the argument
065             */
066            public Value.Type getValueType() {
067                    return valueType;
068            }
069    
070            /**
071             * Returns the name of the argument.
072             * @return the name of the argument
073             */
074            public String getName() {
075                    return name;
076            }
077    
078            /**
079             * Returns whether the parameter is optional.
080             * @return whether the parameter is optional
081             */
082            public boolean isOptional() {
083                    return optional;
084            }
085    
086            /**
087             * Returns the description of the argument.
088             * @return the description of the argument
089             */
090            public String getDescription() {
091                    return description;
092            }
093    
094            /**
095             * Returns a string representation of the parameter.
096             * @return a string representation of the parameter
097             */
098            public String toString() {
099                    return name; // + " (" + valueType + ")";
100            }
101    }