• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.lang3;
18 
19 /**
20  * Thrown to indicate that a block of code has not been implemented.
21  * This exception supplements {@link UnsupportedOperationException}
22  * by providing a more semantically rich description of the problem.
23  *
24  * <p>{@link NotImplementedException} represents the case where the
25  * author has yet to implement the logic at this point in the program.
26  * This can act as an exception based TODO tag.</p>
27  *
28  * <pre>
29  * public void foo() {
30  *   try {
31  *     // do something that throws an Exception
32  *   } catch (Exception ex) {
33  *     // don't know what to do here yet
34  *     throw new NotImplementedException("TODO", ex);
35  *   }
36  * }
37  * </pre>
38  *
39  * This class was originally added in Lang 2.0, but removed in 3.0.
40  *
41  * @since 3.2
42  */
43 public class NotImplementedException extends UnsupportedOperationException {
44 
45     private static final long serialVersionUID = 20131021L;
46 
47     /** A resource for more information regarding the lack of implementation. */
48     private final String code;
49 
50     /**
51      * Constructs a NotImplementedException.
52      *
53      * @since 3.10
54      */
NotImplementedException()55     public NotImplementedException() {
56         this.code = null;
57     }
58 
59     /**
60      * Constructs a NotImplementedException.
61      *
62      * @param message description of the exception
63      * @since 3.2
64      */
NotImplementedException(final String message)65     public NotImplementedException(final String message) {
66         this(message, (String) null);
67     }
68 
69     /**
70      * Constructs a NotImplementedException.
71      *
72      * @param cause cause of the exception
73      * @since 3.2
74      */
NotImplementedException(final Throwable cause)75     public NotImplementedException(final Throwable cause) {
76         this(cause, null);
77     }
78 
79     /**
80      * Constructs a NotImplementedException.
81      *
82      * @param message description of the exception
83      * @param cause cause of the exception
84      * @since 3.2
85      */
NotImplementedException(final String message, final Throwable cause)86     public NotImplementedException(final String message, final Throwable cause) {
87         this(message, cause, null);
88     }
89 
90     /**
91      * Constructs a NotImplementedException.
92      *
93      * @param message description of the exception
94      * @param code code indicating a resource for more information regarding the lack of implementation
95      * @since 3.2
96      */
NotImplementedException(final String message, final String code)97     public NotImplementedException(final String message, final String code) {
98         super(message);
99         this.code = code;
100     }
101 
102     /**
103      * Constructs a NotImplementedException.
104      *
105      * @param cause cause of the exception
106      * @param code code indicating a resource for more information regarding the lack of implementation
107      * @since 3.2
108      */
NotImplementedException(final Throwable cause, final String code)109     public NotImplementedException(final Throwable cause, final String code) {
110         super(cause);
111         this.code = code;
112     }
113 
114     /**
115      * Constructs a NotImplementedException.
116      *
117      * @param message description of the exception
118      * @param cause cause of the exception
119      * @param code code indicating a resource for more information regarding the lack of implementation
120      * @since 3.2
121      */
NotImplementedException(final String message, final Throwable cause, final String code)122     public NotImplementedException(final String message, final Throwable cause, final String code) {
123         super(message, cause);
124         this.code = code;
125     }
126 
127     /**
128      * Obtain the not implemented code. This is an unformatted piece of text intended to point to
129      * further information regarding the lack of implementation. It might, for example, be an issue
130      * tracker ID or a URL.
131      *
132      * @return a code indicating a resource for more information regarding the lack of implementation
133      */
getCode()134     public String getCode() {
135         return this.code;
136     }
137 }
138