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