/*
 *  Draco Econometrics
 *  Copyright (C) 2006-2007 Approximatrix, LLC
 *  http://www.approximatrix.com
 *  
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  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
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.approximatrix.draco.datamodel;

public class Constant {

	private Number value = null;
	private String name = null;
	
	/** Creates a new constant and sets the value to Double(0)
	 * 
	 * @param name the name of the constant
	 */
	public Constant(String name) {
		this.name = name;
		this.value = new Double(0);
	}
	
	/** Creates a new constant with a specified value
	 * 
	 * @param name the name of the variable
	 * @param val the value of the constant
	 */
	public Constant(String name, Number val) {
		this(name);
		if(val != null) 
			this.value = val;
	}
	
	/** Sets the value of a constant
	 * 
	 * @param val the value as a Number
	 */
	public void setValue(Number val) {
		if(val != null)
			value = val;
	}
	
	/** Returns the current constant value as a Number object
	 * 
	 * @return the value of the constant
	 */
	public Number getValue() {
		return value;
	}
	
	/** Returns the class of the constant
	 * 
	 * @return the Class of the constant
	 */
	public Class getConstantClass() {
		if(value != null)
			return value.getClass();
		else
			return null;
	}
	
	/** Returns the name of this constant
	 * 
	 * @return the name of the variable
	 */
	public String getName() {
		return name;
	}
	
}
