View Javadoc
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    *      https://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  
18  /*
19   * This is not the original file distributed by the Apache Software Foundation
20   * It has been modified by the Hipparchus project
21   */
22  package org.hipparchus.migration.exception;
23  
24  import org.hipparchus.exception.Localizable;
25  import org.hipparchus.exception.MathIllegalArgumentException;
26  import org.hipparchus.migration.exception.util.LocalizedFormats;
27  
28  /**
29   * Exception to be thrown when two sets of dimensions differ.
30   *
31   * @deprecated as of 1.0, this exception is replaced by {@link MathIllegalArgumentException}
32   */
33  @Deprecated
34  public class MultiDimensionMismatchException extends MathIllegalArgumentException {
35      /** Serializable version Id. */
36      private static final long serialVersionUID = -8415396756375798143L;
37  
38      /** Wrong dimensions. */
39      private final Integer[] wrong;
40      /** Correct dimensions. */
41      private final Integer[] expected;
42  
43      /**
44       * Construct an exception from the mismatched dimensions.
45       *
46       * @param wrong Wrong dimensions.
47       * @param expected Expected dimensions.
48       */
49      public MultiDimensionMismatchException(Integer[] wrong,
50                                             Integer[] expected) {
51          this(LocalizedFormats.DIMENSIONS_MISMATCH, wrong, expected);
52      }
53  
54      /**
55       * Construct an exception from the mismatched dimensions.
56       *
57       * @param specific Message pattern providing the specific context of
58       * the error.
59       * @param wrong Wrong dimensions.
60       * @param expected Expected dimensions.
61       */
62      public MultiDimensionMismatchException(Localizable specific,
63                                             Integer[] wrong,
64                                             Integer[] expected) {
65          super(specific, wrong, expected);
66          this.wrong = wrong.clone();
67          this.expected = expected.clone();
68      }
69  
70      /** Get array containing the wrong dimensions.
71       * @return an array containing the wrong dimensions
72       */
73      public Integer[] getWrongDimensions() {
74          return wrong.clone();
75      }
76      /** Get array containing the expected dimensions.
77       * @return an array containing the expected dimensions
78       */
79      public Integer[] getExpectedDimensions() {
80          return expected.clone();
81      }
82  
83      /** Get wrong dimension at index.
84       * @param index Dimension index.
85       * @return the wrong dimension stored at {@code index}.
86       */
87      public int getWrongDimension(int index) {
88          return wrong[index].intValue();
89      }
90      /** Get expected dimension at index.
91       * @param index Dimension index.
92       * @return the expected dimension stored at {@code index}.
93       */
94      public int getExpectedDimension(int index) {
95          return expected[index].intValue();
96      }
97  }