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