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    *      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   * <p>Thrown to indicate that a block of code has not been implemented.
21   * This exception supplements <code>UnsupportedOperationException</code>
22   * by providing a more semantically rich description of the problem.</p>
23   * 
24   * <p><code>NotImplementedException</code> 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   * @version $Id: NotImplementedException.java 905636 2010-02-02 14:03:32Z niallp $
43   */
44  public class NotImplementedException extends UnsupportedOperationException {
45  
46      private static final long serialVersionUID = 20131021L;
47  
48      private final String code;
49  
50      /**
51       * Constructs a NotImplementedException.
52       * 
53       * @param message description of the exception
54       * @since 3.2
55       */
56      public NotImplementedException(final String message) {
57          this(message, (String) null);
58      }
59  
60      /**
61       * Constructs a NotImplementedException.
62       * 
63       * @param cause cause of the exception
64       * @since 3.2
65       */
66      public NotImplementedException(final Throwable cause) {
67          this(cause, null);
68      }
69  
70      /**
71       * Constructs a NotImplementedException.
72       * 
73       * @param message description of the exception
74       * @param cause cause of the exception
75       * @since 3.2
76       */
77      public NotImplementedException(final String message, final Throwable cause) {
78          this(message, cause, null);
79      }
80  
81      /**
82       * Constructs a NotImplementedException.
83       * 
84       * @param message description of the exception
85       * @param code code indicating a resource for more information regarding the lack of implementation
86       * @since 3.2
87       */
88      public NotImplementedException(final String message, final String code) {
89          super(message);
90          this.code = code;
91      }
92  
93      /**
94       * Constructs a NotImplementedException.
95       * 
96       * @param cause cause of the exception
97       * @param code code indicating a resource for more information regarding the lack of implementation
98       * @since 3.2
99       */
100     public NotImplementedException(final Throwable cause, final String code) {
101         super(cause);
102         this.code = code;
103     }
104 
105     /**
106      * Constructs a NotImplementedException.
107      * 
108      * @param message description of the exception
109      * @param cause cause of the exception
110      * @param code code indicating a resource for more information regarding the lack of implementation
111      * @since 3.2
112      */
113     public NotImplementedException(final String message, final Throwable cause, final String code) {
114         super(message, cause);
115         this.code = code;
116     }
117 
118     /**
119      * Obtain the not implemented code. This is an unformatted piece of text intended to point to 
120      * further information regarding the lack of implementation. It might, for example, be an issue 
121      * tracker ID or a URL.
122      *
123      * @return a code indicating a resource for more information regarding the lack of implementation
124      */
125     public String getCode() {
126         return this.code;
127     }
128 }