// $Id: Counter.java,v 1.6 2004/02/27 16:30:00 m31 Exp $
//
// This file is part of the program suite "Principia Mathematica II"
// which is a working prototype for the main project:
// "Hilbert II" - http://www.qedeq.org
//
// Copyright 2001-2004  Michael Meyling <mime@qedeq.org>.
//
// "Principia Mathematica II" 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 2 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.

package com.meyling.principia.argument;


/**
 * An object of this class represents a non negative integer.
 *
 * @version $Revision: 1.6 $
 * @author  Michael Meyling
 */
public class Counter extends AbstractArgumentAtom implements Argument,
        CounterMarker {

    /** the plain number */
    private final int number;


    /**
     * Constructs a <code>Number</code>.
     *
     * @param   number  non negative integer (0 is ok)
     * @throws  ArgumentException    if number < 0
     */
    public Counter(final int number) throws ArgumentException {
        if (number < 0) {
            throw new ArgumentException(
                ArgumentConstants.CODE_CONSTRUCTOR_WRONG_ARGUMENT_NUMBER,
                ArgumentConstants.NO_NEGATIVE_INTEGER);
        }
        this.number = number;
    }


    /**
     * Get the number.
     *
     * @return  number
     */
    public final int getNumber() {
        return number;
    }


    /** @inherited */
    public final boolean equals(final Object object) {
        if (object instanceof Counter) {
            return ((Counter) object).number == number;
        } else {
            return false;
        }
    }


    /** @inherited */
    public final Argument copy() {
        return this;
        // no deep necessary as long there could no modifications be done
        // if this changes, the following line should be used:
        // return new Counter(number);
    }


    /** @inherited */
    public final String toString() {
        return Integer.toString(number);
    }


}
