001package com.box.sdkgen.schemas.filebase; 002 003import com.box.sdkgen.internal.Nullable; 004import com.box.sdkgen.internal.NullableFieldTracker; 005import com.box.sdkgen.internal.SerializableObject; 006import com.box.sdkgen.serialization.json.EnumWrapper; 007import com.fasterxml.jackson.annotation.JsonFilter; 008import com.fasterxml.jackson.annotation.JsonProperty; 009import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 010import com.fasterxml.jackson.databind.annotation.JsonSerialize; 011import java.util.Objects; 012 013/** 014 * The bare basic representation of a file, the minimal amount of fields returned when using the 015 * `fields` query parameter. 016 */ 017@JsonFilter("nullablePropertyFilter") 018public class FileBase extends SerializableObject { 019 020 /** 021 * The unique identifier that represent a file. 022 * 023 * <p>The ID for any file can be determined by visiting a file in the web application and copying 024 * the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the `file_id` 025 * is `123`. 026 */ 027 protected final String id; 028 029 /** 030 * The HTTP `etag` of this file. This can be used within some API endpoints in the `If-Match` and 031 * `If-None-Match` headers to only perform changes on the file if (no) changes have happened. 032 */ 033 @Nullable protected String etag; 034 035 /** The value will always be `file`. */ 036 @JsonDeserialize(using = FileBaseTypeField.FileBaseTypeFieldDeserializer.class) 037 @JsonSerialize(using = FileBaseTypeField.FileBaseTypeFieldSerializer.class) 038 protected EnumWrapper<FileBaseTypeField> type; 039 040 public FileBase(@JsonProperty("id") String id) { 041 super(); 042 this.id = id; 043 this.type = new EnumWrapper<FileBaseTypeField>(FileBaseTypeField.FILE); 044 } 045 046 protected FileBase(Builder builder) { 047 super(); 048 this.id = builder.id; 049 this.etag = builder.etag; 050 this.type = builder.type; 051 markNullableFieldsAsSet(builder.getExplicitlySetNullableFields()); 052 } 053 054 public String getId() { 055 return id; 056 } 057 058 public String getEtag() { 059 return etag; 060 } 061 062 public EnumWrapper<FileBaseTypeField> getType() { 063 return type; 064 } 065 066 @Override 067 public boolean equals(Object o) { 068 if (this == o) { 069 return true; 070 } 071 if (o == null || getClass() != o.getClass()) { 072 return false; 073 } 074 FileBase casted = (FileBase) o; 075 return Objects.equals(id, casted.id) 076 && Objects.equals(etag, casted.etag) 077 && Objects.equals(type, casted.type); 078 } 079 080 @Override 081 public int hashCode() { 082 return Objects.hash(id, etag, type); 083 } 084 085 @Override 086 public String toString() { 087 return "FileBase{" 088 + "id='" 089 + id 090 + '\'' 091 + ", " 092 + "etag='" 093 + etag 094 + '\'' 095 + ", " 096 + "type='" 097 + type 098 + '\'' 099 + "}"; 100 } 101 102 public static class Builder extends NullableFieldTracker { 103 104 protected final String id; 105 106 protected String etag; 107 108 protected EnumWrapper<FileBaseTypeField> type; 109 110 public Builder(String id) { 111 super(); 112 this.id = id; 113 } 114 115 public Builder etag(String etag) { 116 this.etag = etag; 117 this.markNullableFieldAsSet("etag"); 118 return this; 119 } 120 121 public Builder type(FileBaseTypeField type) { 122 this.type = new EnumWrapper<FileBaseTypeField>(type); 123 return this; 124 } 125 126 public Builder type(EnumWrapper<FileBaseTypeField> type) { 127 this.type = type; 128 return this; 129 } 130 131 public FileBase build() { 132 if (this.type == null) { 133 this.type = new EnumWrapper<FileBaseTypeField>(FileBaseTypeField.FILE); 134 } 135 return new FileBase(this); 136 } 137 } 138}