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 * Thrown to indicate that a block of code has not been implemented. 021 * This exception supplements {@link UnsupportedOperationException} 022 * by providing a more semantically rich description of the problem. 023 * 024 * <p>{@link 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 /** A resource for more information regarding the lack of implementation. */ 048 private final String code; 049 050 /** 051 * Constructs a NotImplementedException. 052 * 053 * @since 3.10 054 */ 055 public NotImplementedException() { 056 this.code = null; 057 } 058 059 /** 060 * Constructs a NotImplementedException. 061 * 062 * @param message description of the exception 063 * @since 3.2 064 */ 065 public NotImplementedException(final String message) { 066 this(message, (String) null); 067 } 068 069 /** 070 * Constructs a NotImplementedException. 071 * 072 * @param cause cause of the exception 073 * @since 3.2 074 */ 075 public NotImplementedException(final Throwable cause) { 076 this(cause, null); 077 } 078 079 /** 080 * Constructs a NotImplementedException. 081 * 082 * @param message description of the exception 083 * @param cause cause of the exception 084 * @since 3.2 085 */ 086 public NotImplementedException(final String message, final Throwable cause) { 087 this(message, cause, null); 088 } 089 090 /** 091 * Constructs a NotImplementedException. 092 * 093 * @param message description of the exception 094 * @param code code indicating a resource for more information regarding the lack of implementation 095 * @since 3.2 096 */ 097 public NotImplementedException(final String message, final String code) { 098 super(message); 099 this.code = code; 100 } 101 102 /** 103 * Constructs a NotImplementedException. 104 * 105 * @param cause cause of the exception 106 * @param code code indicating a resource for more information regarding the lack of implementation 107 * @since 3.2 108 */ 109 public NotImplementedException(final Throwable cause, final String code) { 110 super(cause); 111 this.code = code; 112 } 113 114 /** 115 * Constructs a NotImplementedException. 116 * 117 * @param message description of the exception 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 String message, final Throwable cause, final String code) { 123 super(message, 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}