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