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 006 * (the "License"); you may not use this file except in compliance with 007 * the 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 019import java.time.*; 020import java.util.function.*; 021 022import org.apache.juneau.http.annotation.*; 023 024/** 025 * Represents a parsed <l>Last-Modified</l> HTTP response header. 026 * 027 * <p> 028 * The last modified date for the requested object (in "HTTP-date" format as defined by RFC 7231). 029 * 030 * <h5 class='figure'>Example</h5> 031 * <p class='bcode'> 032 * Last-Modified: Tue, 15 Nov 1994 12:45:26 GMT 033 * </p> 034 * 035 * <h5 class='topic'>RFC2616 Specification</h5> 036 * 037 * The Last-Modified entity-header field indicates the date and time at which the origin server believes the variant was 038 * last modified. 039 * 040 * <p class='bcode'> 041 * Last-Modified = "Last-Modified" ":" HTTP-date 042 * </p> 043 * 044 * <p> 045 * An example of its use is... 046 * <p class='bcode'> 047 * Last-Modified: Tue, 15 Nov 1994 12:45:26 GMT 048 * </p> 049 * 050 * <p> 051 * The exact meaning of this header field depends on the implementation of the origin server and the nature of the 052 * original resource. 053 * For files, it may be just the file system last-modified time. 054 * For entities with dynamically included parts, it may be the most recent of the set of last-modify times for its 055 * component parts. 056 * For database gateways, it may be the last-update time stamp of the record. 057 * For virtual objects, it may be the last time the internal state changed. 058 * 059 * <p> 060 * An origin server MUST NOT send a Last-Modified date which is later than the server's time of message origination. 061 * In such cases, where the resource's last modification would indicate some time in the future, the server MUST replace 062 * that date with the message origination date. 063 * 064 * <p> 065 * An origin server SHOULD obtain the Last-Modified value of the entity as close as possible to the time that it 066 * generates the Date value of its response. 067 * This allows a recipient to make an accurate assessment of the entity's modification time, especially if the entity 068 * changes near the time that the response is generated. 069 * 070 * <p> 071 * HTTP/1.1 servers SHOULD send Last-Modified whenever feasible. 072 * 073 * <h5 class='section'>See Also:</h5><ul> 074 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauRestCommonBasics">juneau-rest-common Basics</a> 075 * <li class='extlink'><a class="doclink" href="https://www.w3.org/Protocols/rfc2616/rfc2616.html">Hypertext Transfer Protocol -- HTTP/1.1</a> 076 * </ul> 077 * 078 * @serial exclude 079 */ 080@Header("Last-Modified") 081public class LastModified extends BasicDateHeader { 082 083 //----------------------------------------------------------------------------------------------------------------- 084 // Static 085 //----------------------------------------------------------------------------------------------------------------- 086 087 private static final long serialVersionUID = 1L; 088 private static final String NAME = "Last-Modified"; 089 090 /** 091 * Static creator. 092 * 093 * @param value 094 * The header value. 095 * <br>Must be an RFC-1123 formated string (e.g. <js>"Sat, 29 Oct 1994 19:43:31 GMT"</js>). 096 * <br>Can be <jk>null</jk>. 097 * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>. 098 */ 099 public static LastModified of(String value) { 100 return value == null ? null : new LastModified(value); 101 } 102 103 /** 104 * Static creator. 105 * 106 * @param value 107 * The header value. 108 * <br>Can be <jk>null</jk>. 109 * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>. 110 */ 111 public static LastModified of(ZonedDateTime value) { 112 return value == null ? null : new LastModified(value); 113 } 114 115 /** 116 * Static creator with delayed value. 117 * 118 * <p> 119 * Header value is re-evaluated on each call to {@link #getValue()}. 120 * 121 * @param value 122 * The supplier of the header value. 123 * <br>Can be <jk>null</jk>. 124 * @return A new header bean, or <jk>null</jk> if the name is <jk>null</jk> or empty or the value is <jk>null</jk>. 125 */ 126 public static LastModified of(Supplier<ZonedDateTime> value) { 127 return value == null ? null : new LastModified(value); 128 } 129 130 //----------------------------------------------------------------------------------------------------------------- 131 // Instance 132 //----------------------------------------------------------------------------------------------------------------- 133 134 /** 135 * Constructor. 136 * 137 * @param value 138 * The header value. 139 * <br>Must be an RFC-1123 formated string (e.g. <js>"Sat, 29 Oct 1994 19:43:31 GMT"</js>). 140 * <br>Can be <jk>null</jk>. 141 */ 142 public LastModified(String value) { 143 super(NAME, value); 144 } 145 146 /** 147 * Constructor. 148 * 149 * @param value 150 * The header value. 151 * <br>Can be <jk>null</jk>. 152 */ 153 public LastModified(ZonedDateTime value) { 154 super(NAME, value); 155 } 156 157 /** 158 * Constructor with delayed value. 159 * 160 * <p> 161 * Header value is re-evaluated on each call to {@link #getValue()}. 162 * 163 * @param value 164 * The supplier of the header value. 165 * <br>Can be <jk>null</jk>. 166 */ 167 public LastModified(Supplier<ZonedDateTime> value) { 168 super(NAME, value); 169 } 170}