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</code> 022 * by providing a more semantically rich description of the problem.</p> 023 * 024 * <p><code>NotImplementedException</code> 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 * @param message description of the exception 053 * @since 3.2 054 */ 055 public NotImplementedException(final String message) { 056 this(message, (String) null); 057 } 058 059 /** 060 * Constructs a NotImplementedException. 061 * 062 * @param cause cause of the exception 063 * @since 3.2 064 */ 065 public NotImplementedException(final Throwable cause) { 066 this(cause, null); 067 } 068 069 /** 070 * Constructs a NotImplementedException. 071 * 072 * @param message description of the exception 073 * @param cause cause of the exception 074 * @since 3.2 075 */ 076 public NotImplementedException(final String message, final Throwable cause) { 077 this(message, cause, null); 078 } 079 080 /** 081 * Constructs a NotImplementedException. 082 * 083 * @param message description of the exception 084 * @param code code indicating a resource for more information regarding the lack of implementation 085 * @since 3.2 086 */ 087 public NotImplementedException(final String message, final String code) { 088 super(message); 089 this.code = code; 090 } 091 092 /** 093 * Constructs a NotImplementedException. 094 * 095 * @param cause cause of the exception 096 * @param code code indicating a resource for more information regarding the lack of implementation 097 * @since 3.2 098 */ 099 public NotImplementedException(final Throwable cause, final String code) { 100 super(cause); 101 this.code = code; 102 } 103 104 /** 105 * Constructs a NotImplementedException. 106 * 107 * @param message description of the exception 108 * @param cause cause of the exception 109 * @param code code indicating a resource for more information regarding the lack of implementation 110 * @since 3.2 111 */ 112 public NotImplementedException(final String message, final Throwable cause, final String code) { 113 super(message, cause); 114 this.code = code; 115 } 116 117 /** 118 * Obtain the not implemented code. This is an unformatted piece of text intended to point to 119 * further information regarding the lack of implementation. It might, for example, be an issue 120 * tracker ID or a URL. 121 * 122 * @return a code indicating a resource for more information regarding the lack of implementation 123 */ 124 public String getCode() { 125 return this.code; 126 } 127}