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 * @version $Id: NotImplementedException.java 905636 2010-02-02 14:03:32Z niallp $ 043 */ 044public class NotImplementedException extends UnsupportedOperationException { 045 046 private static final long serialVersionUID = 20131021L; 047 048 private final String code; 049 050 /** 051 * Constructs a NotImplementedException. 052 * 053 * @param message description of the exception 054 * @since 3.2 055 */ 056 public NotImplementedException(final String message) { 057 this(message, (String) null); 058 } 059 060 /** 061 * Constructs a NotImplementedException. 062 * 063 * @param cause cause of the exception 064 * @since 3.2 065 */ 066 public NotImplementedException(final Throwable cause) { 067 this(cause, null); 068 } 069 070 /** 071 * Constructs a NotImplementedException. 072 * 073 * @param message description of the exception 074 * @param cause cause of the exception 075 * @since 3.2 076 */ 077 public NotImplementedException(final String message, final Throwable cause) { 078 this(message, cause, null); 079 } 080 081 /** 082 * Constructs a NotImplementedException. 083 * 084 * @param message description of the exception 085 * @param code code indicating a resource for more information regarding the lack of implementation 086 * @since 3.2 087 */ 088 public NotImplementedException(final String message, final String code) { 089 super(message); 090 this.code = code; 091 } 092 093 /** 094 * Constructs a NotImplementedException. 095 * 096 * @param cause cause of the exception 097 * @param code code indicating a resource for more information regarding the lack of implementation 098 * @since 3.2 099 */ 100 public NotImplementedException(final Throwable cause, final String code) { 101 super(cause); 102 this.code = code; 103 } 104 105 /** 106 * Constructs a NotImplementedException. 107 * 108 * @param message description of the exception 109 * @param cause cause of the exception 110 * @param code code indicating a resource for more information regarding the lack of implementation 111 * @since 3.2 112 */ 113 public NotImplementedException(final String message, final Throwable cause, final String code) { 114 super(message, cause); 115 this.code = code; 116 } 117 118 /** 119 * Obtain the not implemented code. This is an unformatted piece of text intended to point to 120 * further information regarding the lack of implementation. It might, for example, be an issue 121 * tracker ID or a URL. 122 * 123 * @return a code indicating a resource for more information regarding the lack of implementation 124 */ 125 public String getCode() { 126 return this.code; 127 } 128}