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   private static final long serialVersionUID = 1L;
047   private static final String NAME = "Debug";
048
049   @SuppressWarnings("javadoc")
050   public static final Debug TRUE = of(true), FALSE = of(false);
051
052   /**
053    * Static creator.
054    *
055    * @param value
056    *    The header value.
057    *    <br>Can be <jk>null</jk>.
058    * @return A new header bean, or <jk>null</jk> if the value was <jk>null</jk>.
059    */
060   public static Debug of(Boolean value) {
061      return value == null ? null : new Debug(value);
062   }
063
064   /**
065    * Static creator.
066    *
067    * @param value
068    *    The header value.
069    *    <br>Must be parsable by {@link Boolean#parseBoolean(String)}.
070    *    <br>Can be <jk>null</jk>.
071    * @return A new header bean, or <jk>null</jk> if the value was <jk>null</jk>.
072    */
073   public static Debug of(String value) {
074      return value == null ? null : new Debug(value);
075   }
076
077   /**
078    * Static creator with delayed value.
079    *
080    * <p>
081    * Header value is re-evaluated on each call to {@link #getValue()}.
082    *
083    * @param value
084    *    The header value supplier.
085    *    <br>Can be <jk>null</jk>.
086    * @return A new header bean, or <jk>null</jk> if the value was <jk>null</jk>.
087    */
088   public static Debug of(Supplier<Boolean> value) {
089      return value == null ? null : new Debug(value);
090   }
091
092   /**
093    * Constructor.
094    *
095    * @param value
096    *    The header value.
097    *    <br>Can be <jk>null</jk>.
098    */
099   public Debug(Boolean value) {
100      super(NAME, value);
101   }
102
103   /**
104    * Constructor.
105    *
106    * @param value
107    *    The header value.
108    *    <br>Must be parsable by {@link Boolean#parseBoolean(String)}.
109    *    <br>Can be <jk>null</jk>.
110    */
111   public Debug(String value) {
112      super(NAME, value);
113   }
114
115   /**
116    * Constructor with delayed value.
117    *
118    * <p>
119    * Header value is re-evaluated on each call to {@link #getValue()}.
120    *
121    * @param value
122    *    The supplier of the header value.
123    *    <br>Can be <jk>null</jk>.
124    */
125   public Debug(Supplier<Boolean> value) {
126      super(NAME, value);
127   }
128}