001// *************************************************************************************************************************** 002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * 003// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * 004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * 005// * with the License. You may obtain a copy of the License at * 006// * * 007// * http://www.apache.org/licenses/LICENSE-2.0 * 008// * * 009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * 010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * 011// * specific language governing permissions and limitations under the License. * 012// *************************************************************************************************************************** 013package org.apache.juneau.http.header; 014 015import java.util.function.*; 016 017import org.apache.juneau.http.annotation.*; 018 019/** 020 * Represents a parsed <l>Debug</l> HTTP request/response header. 021 * 022 * <p> 023 * Specifies to enable debug mode on the current request. 024 * 025 * <h5 class='figure'>Example</h5> 026 * <p class='bcode'> 027 * Debug: true 028 * </p> 029 * 030 * <p> 031 * Not part of the RFC2616 specification, but provided to allow for debugging of HTTP requests. 032 * <br>It's up to the server to decide whether to honor this header. 033 * 034 * <h5 class='section'>See Also:</h5><ul> 035 * <li class='link'><a class="doclink" href="../../../../../index.html#juneau-rest-common">juneau-rest-common</a> 036 * </ul> 037 * 038 * @serial exclude 039 */ 040@Header("Debug") 041public class Debug extends BasicBooleanHeader { 042 043 //----------------------------------------------------------------------------------------------------------------- 044 // Static 045 //----------------------------------------------------------------------------------------------------------------- 046 047 private static final long serialVersionUID = 1L; 048 private static final String NAME = "Debug"; 049 050 @SuppressWarnings("javadoc") 051 public static final Debug TRUE = of(true), FALSE = of(false); 052 053 /** 054 * Static creator. 055 * 056 * @param value 057 * The header value. 058 * <br>Must be parsable by {@link Boolean#parseBoolean(String)}. 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(String 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>Can be <jk>null</jk>. 072 * @return A new header bean, or <jk>null</jk> if the value was <jk>null</jk>. 073 */ 074 public static Debug of(Boolean value) { 075 return value == null ? null : new Debug(value); 076 } 077 078 /** 079 * Static creator with delayed value. 080 * 081 * <p> 082 * Header value is re-evaluated on each call to {@link #getValue()}. 083 * 084 * @param value 085 * The header value supplier. 086 * <br>Can be <jk>null</jk>. 087 * @return A new header bean, or <jk>null</jk> if the value was <jk>null</jk>. 088 */ 089 public static Debug of(Supplier<Boolean> value) { 090 return value == null ? null : new Debug(value); 091 } 092 093 //----------------------------------------------------------------------------------------------------------------- 094 // Instance 095 //----------------------------------------------------------------------------------------------------------------- 096 097 /** 098 * Constructor. 099 * 100 * @param value 101 * The header value. 102 * <br>Must be parsable by {@link Boolean#parseBoolean(String)}. 103 * <br>Can be <jk>null</jk>. 104 */ 105 public Debug(String value) { 106 super(NAME, value); 107 } 108 109 /** 110 * Constructor. 111 * 112 * @param value 113 * The header value. 114 * <br>Can be <jk>null</jk>. 115 */ 116 public Debug(Boolean value) { 117 super(NAME, value); 118 } 119 120 /** 121 * Constructor with delayed value. 122 * 123 * <p> 124 * Header value is re-evaluated on each call to {@link #getValue()}. 125 * 126 * @param value 127 * The supplier of the header value. 128 * <br>Can be <jk>null</jk>. 129 */ 130 public Debug(Supplier<Boolean> value) { 131 super(NAME, value); 132 } 133}