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 */ 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 */ 65 public NotImplementedException(final String message) { 66 this(message, (String) null); 67 } 68 69 /** 70 * Constructs a NotImplementedException. 71 * 72 * @param message description of the exception 73 * @param code code indicating a resource for more information regarding the lack of implementation 74 * @since 3.2 75 */ 76 public NotImplementedException(final String message, final String code) { 77 super(message); 78 this.code = code; 79 } 80 81 /** 82 * Constructs a NotImplementedException. 83 * 84 * @param message description of the exception 85 * @param cause cause of the exception 86 * @since 3.2 87 */ 88 public NotImplementedException(final String message, final Throwable cause) { 89 this(message, cause, null); 90 } 91 92 /** 93 * Constructs a NotImplementedException. 94 * 95 * @param message description of the exception 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 String message, final Throwable cause, final String code) { 101 super(message, cause); 102 this.code = code; 103 } 104 105 /** 106 * Constructs a NotImplementedException. 107 * 108 * @param cause cause of the exception 109 * @since 3.2 110 */ 111 public NotImplementedException(final Throwable cause) { 112 this(cause, null); 113 } 114 115 /** 116 * Constructs a NotImplementedException. 117 * 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 */ 122 public NotImplementedException(final Throwable cause, final String code) { 123 super(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 */ 134 public String getCode() { 135 return this.code; 136 } 137 }