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 (the 006 * "License"); you may not use this file except in compliance with the 007 * 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.header; 018 019 020import java.util.function.*; 021 022import org.apache.juneau.commons.http.*; 023 024 025/** 026 * Represents an HTTP <c>Accept-Encoding</c> header. 027 * 028 * <p> 029 * Acceptable encodings. 030 * 031 * @since 9.2.1 032 */ 033public class AcceptEncoding extends HttpStringRangesHeader { 034 035 public static final String NAME = "Accept-Encoding"; 036 037 /** 038 * Constructor with an eager value. 039 * 040 * @param value The header value. May be <jk>null</jk>. 041 */ 042 public AcceptEncoding(String value) { 043 super(NAME, value); 044 } 045 046 /** 047 * Constructor with an already-parsed value. 048 * 049 * @param value The parsed header value. May be <jk>null</jk>. 050 */ 051 public AcceptEncoding(StringRanges value) { 052 super(NAME, value); 053 } 054 055 private AcceptEncoding(Supplier<?> supplier, int lazyMode) { 056 super(NAME, supplier, lazyMode); 057 } 058 059 /** 060 * Static factory method for a header with an eager value. 061 * 062 * @param value The header value. May be <jk>null</jk>. 063 * @return A new instance. Never <jk>null</jk>. 064 */ 065 public static AcceptEncoding of(String value) { 066 return new AcceptEncoding(value); 067 } 068 069 /** 070 * Static factory method for a header with an already-parsed value. 071 * 072 * @param value The parsed header value. May be <jk>null</jk>. 073 * @return A new instance. Never <jk>null</jk>. 074 */ 075 public static AcceptEncoding of(StringRanges value) { 076 return new AcceptEncoding(value); 077 } 078 079 /** 080 * Static factory method for a header with a lazily-supplied, unparsed wire value. 081 * 082 * @param supplier Supplier for the raw header value string. Must not be <jk>null</jk>. 083 * @return A new instance. Never <jk>null</jk>. 084 */ 085 public static AcceptEncoding ofLazyWire(Supplier<String> supplier) { 086 return new AcceptEncoding(supplier, LAZY_WIRE_STRING); 087 } 088 089 /** 090 * Static factory method for a header with a lazily-supplied, already-parsed value. 091 * 092 * @param supplier Supplier for the parsed header value. Must not be <jk>null</jk>. 093 * @return A new instance. Never <jk>null</jk>. 094 */ 095 public static AcceptEncoding ofLazyParsed(Supplier<StringRanges> supplier) { 096 return new AcceptEncoding(supplier, LAZY_STRING_RANGES); 097 } 098}