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@Header("Forwarded") 023public class Forwarded extends BasicStringHeader { 024 025 private static final long serialVersionUID = 1L; 026 027 /** 028 * Convenience creator. 029 * 030 * @param value 031 * The header value. 032 * <br>Can be any of the following: 033 * <ul> 034 * <li>{@link String} 035 * <li>Anything else - Converted to <c>String</c> then parsed. 036 * </ul> 037 * @return A new {@link Forwarded} object. 038 */ 039 public static Forwarded of(Object value) { 040 if (value == null) 041 return null; 042 return new Forwarded(value); 043 } 044 045 /** 046 * Convenience creator using supplier. 047 * 048 * <p> 049 * Header value is re-evaluated on each call to {@link #getValue()}. 050 * 051 * @param value 052 * The header value supplier. 053 * <br>Can be any of the following: 054 * <ul> 055 * <li>{@link String} 056 * <li>Anything else - Converted to <c>String</c> then parsed. 057 * </ul> 058 * @return A new {@link Forwarded} object. 059 */ 060 public static Forwarded of(Supplier<?> value) { 061 if (value == null) 062 return null; 063 return new Forwarded(value); 064 } 065 066 /** 067 * Constructor. 068 * 069 * @param value 070 * The header value. 071 * <br>Can be any of the following: 072 * <ul> 073 * <li>{@link String} 074 * <li>Anything else - Converted to <c>String</c> then parsed. 075 * <li>A {@link Supplier} of anything on this list. 076 * </ul> 077 */ 078 public Forwarded(Object value) { 079 super("Forwarded", value); 080 } 081 082 /** 083 * Constructor 084 * 085 * @param value 086 * The header value. 087 */ 088 public Forwarded(String value) { 089 this((Object)value); 090 } 091}