NoBracketingException.java

  1. /*
  2.  * Licensed to the Apache Software Foundation (ASF) under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * The ASF licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  *      http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.apache.commons.math4.legacy.exception;

  18. import org.apache.commons.math4.legacy.exception.util.Localizable;
  19. import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;

  20. /**
  21.  * Exception to be thrown when function values have the same sign at both
  22.  * ends of an interval.
  23.  *
  24.  * @since 3.0
  25.  */
  26. public class NoBracketingException extends MathIllegalArgumentException {
  27.     /** Serializable version Id. */
  28.     private static final long serialVersionUID = -3629324471511904459L;
  29.     /** Lower end of the interval. */
  30.     private final double lo;
  31.     /** Higher end of the interval. */
  32.     private final double hi;
  33.     /** Value at lower end of the interval. */
  34.     private final double fLo;
  35.     /** Value at higher end of the interval. */
  36.     private final double fHi;

  37.     /**
  38.      * Construct the exception.
  39.      *
  40.      * @param lo Lower end of the interval.
  41.      * @param hi Higher end of the interval.
  42.      * @param fLo Value at lower end of the interval.
  43.      * @param fHi Value at higher end of the interval.
  44.      */
  45.     public NoBracketingException(double lo, double hi,
  46.                                  double fLo, double fHi) {
  47.         this(LocalizedFormats.SAME_SIGN_AT_ENDPOINTS, lo, hi, fLo, fHi);
  48.     }

  49.     /**
  50.      * Construct the exception with a specific context.
  51.      *
  52.      * @param specific Contextual information on what caused the exception.
  53.      * @param lo Lower end of the interval.
  54.      * @param hi Higher end of the interval.
  55.      * @param fLo Value at lower end of the interval.
  56.      * @param fHi Value at higher end of the interval.
  57.      * @param args Additional arguments.
  58.      */
  59.     public NoBracketingException(Localizable specific,
  60.                                  double lo, double hi,
  61.                                  double fLo, double fHi,
  62.                                  Object... args) {
  63.         super(specific, Double.valueOf(lo), Double.valueOf(hi), Double.valueOf(fLo), Double.valueOf(fHi), args);
  64.         this.lo = lo;
  65.         this.hi = hi;
  66.         this.fLo = fLo;
  67.         this.fHi = fHi;
  68.     }

  69.     /**
  70.      * Get the lower end of the interval.
  71.      *
  72.      * @return the lower end.
  73.      */
  74.     public double getLo() {
  75.         return lo;
  76.     }
  77.     /**
  78.      * Get the higher end of the interval.
  79.      *
  80.      * @return the higher end.
  81.      */
  82.     public double getHi() {
  83.         return hi;
  84.     }
  85.     /**
  86.      * Get the value at the lower end of the interval.
  87.      *
  88.      * @return the value at the lower end.
  89.      */
  90.     public double getFLo() {
  91.         return fLo;
  92.     }
  93.     /**
  94.      * Get the value at the higher end of the interval.
  95.      *
  96.      * @return the value at the higher end.
  97.      */
  98.     public double getFHi() {
  99.         return fHi;
  100.     }
  101. }