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.juneau.http.header;
018
019import java.util.function.*;
020
021import org.apache.juneau.http.annotation.*;
022
023/**
024 * Represents a parsed <l>Debug</l> HTTP request/response header.
025 *
026 * <p>
027 * Specifies to enable debug mode on the current request.
028 *
029 * <h5 class='figure'>Example</h5>
030 * <p class='bcode'>
031 *    Debug: true
032 * </p>
033 *
034 * <p>
035 * Not part of the RFC2616 specification, but provided to allow for debugging of HTTP requests.
036 * <br>It's up to the server to decide whether to honor this header.
037 *
038 * <h5 class='section'>See Also:</h5><ul>
039 *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauRestCommonBasics">juneau-rest-common Basics</a>
040 * </ul>
041 *
042 * @serial exclude
043 */
044@Header("Debug")
045public class Debug extends BasicBooleanHeader {
046
047   //-----------------------------------------------------------------------------------------------------------------
048   // Static
049   //-----------------------------------------------------------------------------------------------------------------
050
051   private static final long serialVersionUID = 1L;
052   private static final String NAME = "Debug";
053
054   @SuppressWarnings("javadoc")
055   public static final Debug TRUE = of(true), FALSE = of(false);
056
057   /**
058    * Static creator.
059    *
060    * @param value
061    *    The header value.
062    *    <br>Must be parsable by {@link Boolean#parseBoolean(String)}.
063    *    <br>Can be <jk>null</jk>.
064    * @return A new header bean, or <jk>null</jk> if the value was <jk>null</jk>.
065    */
066   public static Debug of(String value) {
067      return value == null ? null : new Debug(value);
068   }
069
070   /**
071    * Static creator.
072    *
073    * @param value
074    *    The header value.
075    *    <br>Can be <jk>null</jk>.
076    * @return A new header bean, or <jk>null</jk> if the value was <jk>null</jk>.
077    */
078   public static Debug of(Boolean value) {
079      return value == null ? null : new Debug(value);
080   }
081
082   /**
083    * Static creator with delayed value.
084    *
085    * <p>
086    * Header value is re-evaluated on each call to {@link #getValue()}.
087    *
088    * @param value
089    *    The header value supplier.
090    *    <br>Can be <jk>null</jk>.
091    * @return A new header bean, or <jk>null</jk> if the value was <jk>null</jk>.
092    */
093   public static Debug of(Supplier<Boolean> value) {
094      return value == null ? null : new Debug(value);
095   }
096
097   //-----------------------------------------------------------------------------------------------------------------
098   // Instance
099   //-----------------------------------------------------------------------------------------------------------------
100
101   /**
102    * Constructor.
103    *
104    * @param value
105    *    The header value.
106    *    <br>Must be parsable by {@link Boolean#parseBoolean(String)}.
107    *    <br>Can be <jk>null</jk>.
108    */
109   public Debug(String value) {
110      super(NAME, value);
111   }
112
113   /**
114    * Constructor.
115    *
116    * @param value
117    *    The header value.
118    *    <br>Can be <jk>null</jk>.
119    */
120   public Debug(Boolean value) {
121      super(NAME, value);
122   }
123
124   /**
125    * Constructor with delayed value.
126    *
127    * <p>
128    * Header value is re-evaluated on each call to {@link #getValue()}.
129    *
130    * @param value
131    *    The supplier of the header value.
132    *    <br>Can be <jk>null</jk>.
133    */
134   public Debug(Supplier<Boolean> value) {
135      super(NAME, value);
136   }
137}