    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 *      https://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 message description of the exception
    073     * @param code code indicating a resource for more information regarding the lack of implementation
    074     * @since 3.2
    075     */
    076    public NotImplementedException(final String message, final String code) {
    077        super(message);
    078        this.code = code;
    079    }
    080
    081    /**
    082     * Constructs a NotImplementedException.
    083     *
    084     * @param message description of the exception
    085     * @param cause cause of the exception
    086     * @since 3.2
    087     */
    088    public NotImplementedException(final String message, final Throwable cause) {
    089        this(message, cause, null);
    090    }
    091
    092    /**
    093     * Constructs a NotImplementedException.
    094     *
    095     * @param message description of the exception
    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 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}