source: src/main/java/agents/anac/y2019/harddealer/math3/exception/MultiDimensionMismatchException.java

Last change on this file was 204, checked in by Katsuhide Fujita, 5 years ago

Fixed errors of ANAC2019 agents

  • Property svn:executable set to *
File size: 3.0 KB
Line 
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 */
17package agents.anac.y2019.harddealer.math3.exception;
18
19import agents.anac.y2019.harddealer.math3.exception.util.Localizable;
20import agents.anac.y2019.harddealer.math3.exception.util.LocalizedFormats;
21
22/**
23 * Exception to be thrown when two sets of dimensions differ.
24 *
25 * @since 3.0
26 */
27public class MultiDimensionMismatchException extends MathIllegalArgumentException {
28 /** Serializable version Id. */
29 private static final long serialVersionUID = -8415396756375798143L;
30
31 /** Wrong dimensions. */
32 private final Integer[] wrong;
33 /** Correct dimensions. */
34 private final Integer[] expected;
35
36 /**
37 * Construct an exception from the mismatched dimensions.
38 *
39 * @param wrong Wrong dimensions.
40 * @param expected Expected dimensions.
41 */
42 public MultiDimensionMismatchException(Integer[] wrong,
43 Integer[] expected) {
44 this(LocalizedFormats.DIMENSIONS_MISMATCH, wrong, expected);
45 }
46
47 /**
48 * Construct an exception from the mismatched dimensions.
49 *
50 * @param specific Message pattern providing the specific context of
51 * the error.
52 * @param wrong Wrong dimensions.
53 * @param expected Expected dimensions.
54 */
55 public MultiDimensionMismatchException(Localizable specific,
56 Integer[] wrong,
57 Integer[] expected) {
58 super(specific, wrong, expected);
59 this.wrong = wrong.clone();
60 this.expected = expected.clone();
61 }
62
63 /**
64 * @return an array containing the wrong dimensions.
65 */
66 public Integer[] getWrongDimensions() {
67 return wrong.clone();
68 }
69 /**
70 * @return an array containing the expected dimensions.
71 */
72 public Integer[] getExpectedDimensions() {
73 return expected.clone();
74 }
75
76 /**
77 * @param index Dimension index.
78 * @return the wrong dimension stored at {@code index}.
79 */
80 public int getWrongDimension(int index) {
81 return wrong[index].intValue();
82 }
83 /**
84 * @param index Dimension index.
85 * @return the expected dimension stored at {@code index}.
86 */
87 public int getExpectedDimension(int index) {
88 return expected[index].intValue();
89 }
90}
Note: See TracBrowser for help on using the repository browser.