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
022/**
023 * Represents an HTTP <c>Content-Length</c> header.
024 *
025 * <p>
026 * The size of the entity-body in bytes.
027 *
028 * @since 9.2.1
029 */
030public class ContentLength extends HttpLongHeader {
031
032   public static final String NAME = "Content-Length";
033
034   public ContentLength(String value) {
035      super(NAME, value);
036   }
037
038   public ContentLength(long value) {
039      super(NAME, Long.valueOf(value));
040   }
041
042   public ContentLength(Long value) {
043      super(NAME, value);
044   }
045
046   private ContentLength(Supplier<?> supplier, int lazyMode) {
047      super(NAME, supplier, lazyMode);
048   }
049
050   public static ContentLength of(String value) {
051      return new ContentLength(value);
052   }
053
054   public static ContentLength of(long value) {
055      return new ContentLength(value);
056   }
057
058   public static ContentLength of(Long value) {
059      return new ContentLength(value);
060   }
061
062   public static ContentLength ofLazyWire(Supplier<String> supplier) {
063      return new ContentLength(supplier, LAZY_WIRE_STRING);
064   }
065
066   public static ContentLength ofLazyParsed(Supplier<Long> supplier) {
067      return new ContentLength(supplier, LAZY_LONG);
068   }
069}