001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.commons.math3.exception;
018
019 import org.apache.commons.math3.exception.util.Localizable;
020
021 /**
022 * Base class for exceptions raised by a wrong number.
023 * This class is not intended to be instantiated directly: it should serve
024 * as a base class to create all the exceptions that are raised because some
025 * precondition is violated by a number argument.
026 *
027 * @since 2.2
028 * @version $Id: MathIllegalNumberException.java 1364378 2012-07-22 17:42:38Z tn $
029 */
030 public class MathIllegalNumberException extends MathIllegalArgumentException {
031 /** Serializable version Id. */
032 private static final long serialVersionUID = -7447085893598031110L;
033 /** Requested. */
034 private final Number argument;
035
036 /**
037 * Construct an exception.
038 *
039 * @param pattern Localizable pattern.
040 * @param wrong Wrong number.
041 * @param arguments Arguments.
042 */
043 protected MathIllegalNumberException(Localizable pattern,
044 Number wrong,
045 Object ... arguments) {
046 super(pattern, wrong, arguments);
047 argument = wrong;
048 }
049
050 /**
051 * @return the requested value.
052 */
053 public Number getArgument() {
054 return argument;
055 }
056 }