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>Forwarded</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 *    <li class='extlink'><a class="doclink" href="https://www.w3.org/Protocols/rfc2616/rfc2616.html">Hypertext Transfer Protocol -- HTTP/1.1</a>
025 * </ul>
026 *
027 * @serial exclude
028 */
029@Header("Forwarded")
030public class Forwarded extends BasicStringHeader {
031
032   //-----------------------------------------------------------------------------------------------------------------
033   // Static
034   //-----------------------------------------------------------------------------------------------------------------
035
036   private static final long serialVersionUID = 1L;
037   private static final String NAME = "Forwarded";
038
039   /**
040    * Static creator.
041    *
042    * @param value
043    *    The header value.
044    *    <br>Can be <jk>null</jk>.
045    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
046    */
047   public static Forwarded of(String value) {
048      return value == null ? null : new Forwarded(value);
049   }
050
051   /**
052    * Static creator with delayed value.
053    *
054    * <p>
055    * Header value is re-evaluated on each call to {@link #getValue()}.
056    *
057    * @param value
058    *    The supplier of the header value.
059    *    <br>Can be <jk>null</jk>.
060    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
061    */
062   public static Forwarded of(Supplier<String> value) {
063      return value == null ? null : new Forwarded(value);
064   }
065
066   //-----------------------------------------------------------------------------------------------------------------
067   // Instance
068   //-----------------------------------------------------------------------------------------------------------------
069
070   /**
071    * Constructor.
072    *
073    * @param value
074    *    The header value.
075    *    <br>Can be <jk>null</jk>.
076    */
077   public Forwarded(String value) {
078      super(NAME, value);
079   }
080
081   /**
082    * Constructor with delayed value.
083    *
084    * <p>
085    * Header value is re-evaluated on each call to {@link #getValue()}.
086    *
087    * @param value
088    *    The supplier of the header value.
089    *    <br>Can be <jk>null</jk>.
090    */
091   public Forwarded(Supplier<String> value) {
092      super(NAME, value);
093   }
094}