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>No-Trace</l> HTTP request header.
021 *
022 * <h5 class='section'>See Also:</h5><ul>
023 *    <li class='link'><a class="doclink" href="../../../../../index.html#juneau-rest-common">juneau-rest-common</a>
024 * </ul>
025 *
026 * @serial exclude
027 */
028@Header("No-Trace")
029public class NoTrace extends BasicBooleanHeader {
030
031   //-----------------------------------------------------------------------------------------------------------------
032   // Static
033   //-----------------------------------------------------------------------------------------------------------------
034
035   private static final long serialVersionUID = 1L;
036   private static final String NAME = "No-Trace";
037
038   @SuppressWarnings("javadoc")
039   public static final NoTrace TRUE = of(true), FALSE = of(false);
040
041   /**
042    * Static creator.
043    *
044    * @param value
045    *    The header value.
046    *    <br>Must be parsable by {@link Boolean#parseBoolean(String)}.
047    *    <br>Can be <jk>null</jk>.
048    * @return A new header bean, or <jk>null</jk> if the value was <jk>null</jk>.
049    */
050   public static NoTrace of(String value) {
051      return value == null ? null : new NoTrace(value);
052   }
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 NoTrace of(Boolean value) {
063      return value == null ? null : new NoTrace(value);
064   }
065
066   /**
067    * Static creator with delayed value.
068    *
069    * <p>
070    * Header value is re-evaluated on each call to {@link #getValue()}.
071    *
072    * @param value
073    *    The header value supplier.
074    *    <br>Can be <jk>null</jk>.
075    * @return A new header bean, or <jk>null</jk> if the value was <jk>null</jk>.
076    */
077   public static NoTrace of(Supplier<Boolean> value) {
078      return value == null ? null : new NoTrace(value);
079   }
080
081   //-----------------------------------------------------------------------------------------------------------------
082   // Instance
083   //-----------------------------------------------------------------------------------------------------------------
084
085   /**
086    * Constructor.
087    *
088    * @param value
089    *    The header value.
090    *    <br>Must be parsable by {@link Boolean#parseBoolean(String)}.
091    *    <br>Can be <jk>null</jk>.
092    */
093   public NoTrace(String value) {
094      super(NAME, value);
095   }
096
097   /**
098    * Constructor.
099    *
100    * @param value
101    *    The header value.
102    *    <br>Can be <jk>null</jk>.
103    */
104   public NoTrace(Boolean value) {
105      super(NAME, value);
106   }
107
108   /**
109    * Constructor with delayed value.
110    *
111    * <p>
112    * Header value is re-evaluated on each call to {@link #getValue()}.
113    *
114    * @param value
115    *    The supplier of the header value.
116    *    <br>Can be <jk>null</jk>.
117    */
118   public NoTrace(Supplier<Boolean> value) {
119      super(NAME, value);
120   }
121}