View Javadoc

1   /*******************************************************************************
2    * Copyright 2013 André Rouél and Dominik Seichter
3    * 
4    * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
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  package net.sf.qualitycheck.exception;
17  
18  import javax.annotation.Nonnull;
19  import javax.annotation.Nullable;
20  
21  /**
22   * Thrown to indicate that a method was passed arguments which was expected
23   * to be equal to another object but was not.
24   * 
25   * @author André Rouél
26   * @author Dominik Seichter
27   */
28  public class IllegalNotEqualException extends RuntimeException {
29  
30  	private static final long serialVersionUID = 49779498587504287L;
31  
32  	/**
33  	 * Default message to indicate that the given arguments must be equal to another object.
34  	 */
35  	protected static final String DEFAULT_MESSAGE = "Argument must be equal to a defined value.";
36  	
37  	/**
38  	 * Constructs an {@code IllegalNotEqualException} with the default message
39  	 * {@link IllegalNotEqualException#DEFAULT_MESSAGE}.
40  	 */
41  	public IllegalNotEqualException() {
42  		super(DEFAULT_MESSAGE);
43  	}
44  
45  	/**
46  	 * Constructs an {@code IllegalNotEqualException} with a given message.
47  	 * 
48  	 * @param message
49  	 *            explains why the object must equal another object
50  	 */
51  	public IllegalNotEqualException(@Nonnull final String message) {
52  		super(message);
53  	}
54  
55  	/**
56  	 * Constructs a new exception with a given message.
57  	 * 
58  	 * @param message
59  	 *            explains why the object must equal another object
60  	 * @param cause
61  	 *            the cause (which is saved for later retrieval by the {@link Throwable#getCause()} method). (A
62  	 *            {@code null} value is permitted, and indicates that the cause is nonexistent or unknown.)
63  	 */
64  	public IllegalNotEqualException(@Nonnull final String message, @Nullable final Throwable cause) {
65  		super(message, cause);
66  	}
67  	
68  	/**
69  	 * Constructs a new exception with the default message {@link IllegalNotEqualException#DEFAULT_MESSAGE}.
70  	 * 
71  	 * @param cause
72  	 *            the cause (which is saved for later retrieval by the {@link Throwable#getCause()} method). (A
73  	 *            {@code null} value is permitted, and indicates that the cause is nonexistent or unknown.)
74  	 */
75  	public IllegalNotEqualException(@Nullable final Throwable cause) {
76  		super(DEFAULT_MESSAGE, cause);
77  	}
78  
79  }