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.response;
014
015import static org.apache.juneau.http.response.NotModified.*;
016
017import java.net.*;
018import java.util.*;
019
020import org.apache.http.*;
021import org.apache.http.Header;
022import org.apache.juneau.annotation.*;
023import org.apache.juneau.http.*;
024import org.apache.juneau.http.annotation.*;
025import org.apache.juneau.http.header.*;
026import org.apache.juneau.internal.*;
027
028/**
029 * Represents an <c>HTTP 304 Not Modified</c> response.
030 *
031 * <p>
032 * Indicates that the resource has not been modified since the version specified by the request headers If-Modified-Since or If-None-Match.
033 * In such case, there is no need to retransmit the resource since the client still has a previously-downloaded copy.
034 *
035 * <h5 class='section'>See Also:</h5><ul>
036 *    <li class='link'><a class="doclink" href="../../../../../index.html#juneau-rest-common">juneau-rest-common</a>
037 * </ul>
038 */
039@Response
040@StatusCode(STATUS_CODE)
041@Schema(description=REASON_PHRASE)
042@FluentSetters
043public class NotModified extends BasicHttpResponse {
044
045   /** HTTP status code */
046   public static final int STATUS_CODE = 304;
047
048   /** Reason phrase */
049   public static final String REASON_PHRASE = "Not Modified";
050
051   /** Default status line */
052   private static final BasicStatusLine STATUS_LINE = BasicStatusLine.create(STATUS_CODE, REASON_PHRASE);
053
054   /** Default unmodifiable instance */
055   public static final NotModified INSTANCE = new NotModified().setUnmodifiable();
056
057   /**
058    * Constructor.
059    */
060   public NotModified() {
061      super(STATUS_LINE);
062   }
063
064   /**
065    * Copy constructor.
066    *
067    * @param copyFrom The bean to copy from.
068    */
069   public NotModified(NotModified copyFrom) {
070      super(copyFrom);
071   }
072
073   /**
074    * Constructor.
075    *
076    * <p>
077    * This is the constructor used when parsing an HTTP response.
078    *
079    * @param response The HTTP response to copy from.  Must not be <jk>null</jk>.
080    * @throws AssertionError If HTTP response status code does not match what was expected.
081    */
082   public NotModified(HttpResponse response) {
083      super(response);
084      assertStatusCode(response);
085   }
086
087   /**
088    * Creates a builder for this class initialized with the contents of this bean.
089    *
090    * @return A new builder bean.
091    */
092   public NotModified copy() {
093      return new NotModified(this);
094   }
095
096   // <FluentSetters>
097
098   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
099   public NotModified setContent(String value) {
100      super.setContent(value);
101      return this;
102   }
103
104   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
105   public NotModified setContent(HttpEntity value) {
106      super.setContent(value);
107      return this;
108   }
109
110   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
111   public NotModified setHeader2(Header value) {
112      super.setHeader2(value);
113      return this;
114   }
115
116   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
117   public NotModified setHeader2(String name, String value) {
118      super.setHeader2(name, value);
119      return this;
120   }
121
122   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
123   public NotModified setHeaders(List<Header> values) {
124      super.setHeaders(values);
125      return this;
126   }
127
128   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
129   public NotModified setHeaders(HeaderList value) {
130      super.setHeaders(value);
131      return this;
132   }
133
134   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
135   public NotModified setHeaders2(Header...values) {
136      super.setHeaders2(values);
137      return this;
138   }
139
140   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
141   public NotModified setLocale2(Locale value) {
142      super.setLocale2(value);
143      return this;
144   }
145
146   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
147   public NotModified setLocation(String value) {
148      super.setLocation(value);
149      return this;
150   }
151
152   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
153   public NotModified setLocation(URI value) {
154      super.setLocation(value);
155      return this;
156   }
157
158   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
159   public NotModified setProtocolVersion(ProtocolVersion value) {
160      super.setProtocolVersion(value);
161      return this;
162   }
163
164   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
165   public NotModified setReasonPhrase2(String value) {
166      super.setReasonPhrase2(value);
167      return this;
168   }
169
170   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
171   public NotModified setReasonPhraseCatalog(ReasonPhraseCatalog value) {
172      super.setReasonPhraseCatalog(value);
173      return this;
174   }
175
176   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
177   public NotModified setStatusCode2(int value) {
178      super.setStatusCode2(value);
179      return this;
180   }
181
182   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
183   public NotModified setStatusLine(BasicStatusLine value) {
184      super.setStatusLine(value);
185      return this;
186   }
187
188   @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */
189   public NotModified setUnmodifiable() {
190      super.setUnmodifiable();
191      return this;
192   }
193
194   // </FluentSetters>
195}