001package com.box.sdkgen.managers.chunkeduploads; 002 003import static com.box.sdkgen.internal.utils.UtilsManager.mapOf; 004 005import java.util.Map; 006 007public class CreateFileUploadSessionCommitHeaders { 008 009 /** 010 * The [RFC3230][1] message digest of the whole file. 011 * 012 * <p>Only SHA1 is supported. The SHA1 digest must be Base64 encoded. The format of this header is 013 * as `sha=BASE64_ENCODED_DIGEST`. 014 * 015 * <p>[1]: https://tools.ietf.org/html/rfc3230 016 */ 017 public final String digest; 018 019 /** 020 * Ensures this item hasn't recently changed before making changes. 021 * 022 * <p>Pass in the item's last observed `etag` value into this header and the endpoint will fail 023 * with a `412 Precondition Failed` if it has changed since. 024 */ 025 public String ifMatch; 026 027 /** 028 * Ensures an item is only returned if it has changed. 029 * 030 * <p>Pass in the item's last observed `etag` value into this header and the endpoint will fail 031 * with a `304 Not Modified` if the item has not changed since. 032 */ 033 public String ifNoneMatch; 034 035 /** Extra headers that will be included in the HTTP request. */ 036 public Map<String, String> extraHeaders; 037 038 public CreateFileUploadSessionCommitHeaders(String digest) { 039 this.digest = digest; 040 this.extraHeaders = mapOf(); 041 } 042 043 protected CreateFileUploadSessionCommitHeaders(Builder builder) { 044 this.digest = builder.digest; 045 this.ifMatch = builder.ifMatch; 046 this.ifNoneMatch = builder.ifNoneMatch; 047 this.extraHeaders = builder.extraHeaders; 048 } 049 050 public String getDigest() { 051 return digest; 052 } 053 054 public String getIfMatch() { 055 return ifMatch; 056 } 057 058 public String getIfNoneMatch() { 059 return ifNoneMatch; 060 } 061 062 public Map<String, String> getExtraHeaders() { 063 return extraHeaders; 064 } 065 066 public static class Builder { 067 068 protected final String digest; 069 070 protected String ifMatch; 071 072 protected String ifNoneMatch; 073 074 protected Map<String, String> extraHeaders; 075 076 public Builder(String digest) { 077 this.digest = digest; 078 } 079 080 public Builder ifMatch(String ifMatch) { 081 this.ifMatch = ifMatch; 082 return this; 083 } 084 085 public Builder ifNoneMatch(String ifNoneMatch) { 086 this.ifNoneMatch = ifNoneMatch; 087 return this; 088 } 089 090 public Builder extraHeaders(Map<String, String> extraHeaders) { 091 this.extraHeaders = extraHeaders; 092 return this; 093 } 094 095 public CreateFileUploadSessionCommitHeaders build() { 096 if (this.extraHeaders == null) { 097 this.extraHeaders = mapOf(); 098 } 099 return new CreateFileUploadSessionCommitHeaders(this); 100 } 101 } 102}