001package com.box.sdkgen.managers.uploads; 002 003import static com.box.sdkgen.internal.utils.UtilsManager.mapOf; 004 005import java.util.Map; 006 007public class UploadFileVersionHeaders { 008 009 /** 010 * Ensures this item hasn't recently changed before making changes. 011 * 012 * <p>Pass in the item's last observed `etag` value into this header and the endpoint will fail 013 * with a `412 Precondition Failed` if it has changed since. 014 */ 015 public String ifMatch; 016 017 /** 018 * An optional header containing the SHA1 hash of the file to ensure that the file was not 019 * corrupted in transit. 020 */ 021 public String contentMd5; 022 023 /** Extra headers that will be included in the HTTP request. */ 024 public Map<String, String> extraHeaders; 025 026 public UploadFileVersionHeaders() { 027 this.extraHeaders = mapOf(); 028 } 029 030 protected UploadFileVersionHeaders(Builder builder) { 031 this.ifMatch = builder.ifMatch; 032 this.contentMd5 = builder.contentMd5; 033 this.extraHeaders = builder.extraHeaders; 034 } 035 036 public String getIfMatch() { 037 return ifMatch; 038 } 039 040 public String getContentMd5() { 041 return contentMd5; 042 } 043 044 public Map<String, String> getExtraHeaders() { 045 return extraHeaders; 046 } 047 048 public static class Builder { 049 050 protected String ifMatch; 051 052 protected String contentMd5; 053 054 protected Map<String, String> extraHeaders; 055 056 public Builder() {} 057 058 public Builder ifMatch(String ifMatch) { 059 this.ifMatch = ifMatch; 060 return this; 061 } 062 063 public Builder contentMd5(String contentMd5) { 064 this.contentMd5 = contentMd5; 065 return this; 066 } 067 068 public Builder extraHeaders(Map<String, String> extraHeaders) { 069 this.extraHeaders = extraHeaders; 070 return this; 071 } 072 073 public UploadFileVersionHeaders build() { 074 if (this.extraHeaders == null) { 075 this.extraHeaders = mapOf(); 076 } 077 return new UploadFileVersionHeaders(this); 078 } 079 } 080}