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:
018: package java.lang;
019:
020: /**
021: * Indicates that an assertion has failed.
022: *
023: * @since 1.4
024: */
025: public class AssertionError extends Error {
026:
027: private static final long serialVersionUID = -5013299493970297370L;
028:
029: /**
030: * Constructs an instance without a message.
031: */
032: public AssertionError() {
033: super ();
034: }
035:
036: /**
037: * Constructs an instance with a message that is the
038: * {@link String#valueOf(Object)} of the object passed. If the object passed
039: * is an instance of {@link Throwable}, then it also becomes the cause of
040: * this error.
041: *
042: * @param detailMessage
043: * The value to be converted into the message and optionally the
044: * cause.
045: */
046: public AssertionError(Object detailMessage) {
047: super (
048: String.valueOf(detailMessage),
049: (detailMessage instanceof Throwable ? (Throwable) detailMessage
050: : null));
051: }
052:
053: /**
054: * Constructs an instance with a message that is the
055: * {@link String#valueOf(boolean)} of the boolean passed.
056: *
057: * @param detailMessage
058: * The value to be converted into the message.
059: */
060: public AssertionError(boolean detailMessage) {
061: this (String.valueOf(detailMessage));
062: }
063:
064: /**
065: * Constructs an instance with a message that is the
066: * {@link String#valueOf(char)} of the char passed.
067: *
068: * @param detailMessage
069: * The value to be converted into the message.
070: */
071: public AssertionError(char detailMessage) {
072: this (String.valueOf(detailMessage));
073: }
074:
075: /**
076: * Constructs an instance with a message that is the
077: * {@link String#valueOf(int)} of the int passed.
078: *
079: * @param detailMessage
080: * The value to be converted into the message.
081: */
082: public AssertionError(int detailMessage) {
083: this (Integer.toString(detailMessage));
084: }
085:
086: /**
087: * Constructs an instance with a message that is the
088: * {@link String#valueOf(long)} of the long passed.
089: *
090: * @param detailMessage
091: * The value to be converted into the message.
092: */
093: public AssertionError(long detailMessage) {
094: this (Long.toString(detailMessage));
095: }
096:
097: /**
098: * Constructs an instance with a message that is the
099: * {@link String#valueOf(float)} of the float passed.
100: *
101: * @param detailMessage
102: * The value to be converted into the message.
103: */
104: public AssertionError(float detailMessage) {
105: this (Float.toString(detailMessage));
106: }
107:
108: /**
109: * Constructs an instance with a message that is the
110: * {@link String#valueOf(double)} of the double passed.
111: *
112: * @param detailMessage
113: * The value to be converted into the message.
114: */
115: public AssertionError(double detailMessage) {
116: this(Double.toString(detailMessage));
117: }
118: }
|