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 */ 017package org.apache.commons.lang3; 018 019/** 020 * <p>Thrown to indicate that a block of code has not been implemented. 021 * This exception supplements {@code UnsupportedOperationException} 022 * by providing a more semantically rich description of the problem.</p> 023 * 024 * <p>{@code NotImplementedException} represents the case where the 025 * author has yet to implement the logic at this point in the program. 026 * This can act as an exception based TODO tag. </p> 027 * 028 * <pre> 029 * public void foo() { 030 * try { 031 * // do something that throws an Exception 032 * } catch (Exception ex) { 033 * // don't know what to do here yet 034 * throw new NotImplementedException("TODO", ex); 035 * } 036 * } 037 * </pre> 038 * 039 * This class was originally added in Lang 2.0, but removed in 3.0. 040 * 041 * @since 3.2 042 */ 043public class NotImplementedException extends UnsupportedOperationException { 044 045 private static final long serialVersionUID = 20131021L; 046 047 private final String code; 048 049 /** 050 * Constructs a NotImplementedException. 051 * 052 * @since 3.10 053 */ 054 public NotImplementedException() { 055 this.code = null; 056 } 057 058 /** 059 * Constructs a NotImplementedException. 060 * 061 * @param message description of the exception 062 * @since 3.2 063 */ 064 public NotImplementedException(final String message) { 065 this(message, (String) null); 066 } 067 068 /** 069 * Constructs a NotImplementedException. 070 * 071 * @param cause cause of the exception 072 * @since 3.2 073 */ 074 public NotImplementedException(final Throwable cause) { 075 this(cause, null); 076 } 077 078 /** 079 * Constructs a NotImplementedException. 080 * 081 * @param message description of the exception 082 * @param cause cause of the exception 083 * @since 3.2 084 */ 085 public NotImplementedException(final String message, final Throwable cause) { 086 this(message, cause, null); 087 } 088 089 /** 090 * Constructs a NotImplementedException. 091 * 092 * @param message description of the exception 093 * @param code code indicating a resource for more information regarding the lack of implementation 094 * @since 3.2 095 */ 096 public NotImplementedException(final String message, final String code) { 097 super(message); 098 this.code = code; 099 } 100 101 /** 102 * Constructs a NotImplementedException. 103 * 104 * @param cause cause of the exception 105 * @param code code indicating a resource for more information regarding the lack of implementation 106 * @since 3.2 107 */ 108 public NotImplementedException(final Throwable cause, final String code) { 109 super(cause); 110 this.code = code; 111 } 112 113 /** 114 * Constructs a NotImplementedException. 115 * 116 * @param message description of the exception 117 * @param cause cause of the exception 118 * @param code code indicating a resource for more information regarding the lack of implementation 119 * @since 3.2 120 */ 121 public NotImplementedException(final String message, final Throwable cause, final String code) { 122 super(message, cause); 123 this.code = code; 124 } 125 126 /** 127 * Obtain the not implemented code. This is an unformatted piece of text intended to point to 128 * further information regarding the lack of implementation. It might, for example, be an issue 129 * tracker ID or a URL. 130 * 131 * @return a code indicating a resource for more information regarding the lack of implementation 132 */ 133 public String getCode() { 134 return this.code; 135 } 136}