1  /*
     2   * Copyright the original author or authors.
     3   * 
     4   * Licensed under the MOZILLA PUBLIC LICENSE, Version 1.1 (the "License");
     5   * you may not use this file except in compliance with the License.
     6   * You may obtain a copy of the License at
     7   * 
     8   *      http://www.mozilla.org/MPL/MPL-1.1.html
     9   * 
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   * See the License for the specific language governing permissions and
    14   * limitations under the License.
    15   */
    16  
    17  import org.as2lib.data.type.Integer;
    18  import org.as2lib.data.type.NumberFormatException;
    19  
    20  /**
    21   * {@code NaturalNumberIncludingZero} represents a natural number including zero.
    22   *
    23   * <p>Natural numbers are positive integers including 0. If you do not want to allow
    24   * 0 use {@code NaturalNumber} instead.
    25   * 
    26   * @author Martin Heidegger
    27   * @see org.as2lib.data.type.NaturalNumber
    28   */
    29  class org.as2lib.data.type.NaturalNumberIncludingZero extends Integer {
    30  	
    31  	/**
    32  	 * Constructs a new {@code NaturalNumberIncludingZero} instance.
    33  	 * 
    34  	 * <p>Decimal places are cropped from the passed-in {@code number} if it has at least
    35  	 * one. The passed-in {@code number} must also not be negative.
    36  	 * 
    37  	 * @param number the natural number
    38  	 * @throws NumberFormatException if the passed-in {@code number} is negative number
    39  	 * or (-)infinity
    40  	 */
    41  	public function NaturalNumberIncludingZero(number:Number) {
    42  		super (number);
    43  		if (int < 0) {
    44  			throw new NumberFormatException("Natural numbers don't inlude negative numbers like: "+number+".", this, arguments);
    45  		}
    46  	}
    47  }