001package com.box.sdkgen.schemas.metadatatemplate; 002 003import com.box.sdkgen.internal.NullableFieldTracker; 004import com.box.sdkgen.internal.SerializableObject; 005import com.box.sdkgen.serialization.json.EnumWrapper; 006import com.fasterxml.jackson.annotation.JsonFilter; 007import com.fasterxml.jackson.annotation.JsonProperty; 008import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 009import com.fasterxml.jackson.databind.annotation.JsonSerialize; 010import java.util.List; 011import java.util.Objects; 012 013@JsonFilter("nullablePropertyFilter") 014public class MetadataTemplateFieldsField extends SerializableObject { 015 016 /** 017 * The type of field. The basic fields are a `string` field for text, a `float` field for numbers, 018 * and a `date` fields to present the user with a date-time picker. 019 * 020 * <p>Additionally, metadata templates support an `enum` field for a basic list of items, and ` 021 * multiSelect` field for a similar list of items where the user can select more than one value. 022 * 023 * <p>**Note**: The `integer` value is deprecated. It is still present in the response, but cannot 024 * be used in the POST request. 025 */ 026 @JsonDeserialize( 027 using = MetadataTemplateFieldsTypeField.MetadataTemplateFieldsTypeFieldDeserializer.class) 028 @JsonSerialize( 029 using = MetadataTemplateFieldsTypeField.MetadataTemplateFieldsTypeFieldSerializer.class) 030 protected final EnumWrapper<MetadataTemplateFieldsTypeField> type; 031 032 /** 033 * A unique identifier for the field. The identifier must be unique within the template to which 034 * it belongs. 035 */ 036 protected final String key; 037 038 /** The display name of the field as it is shown to the user in the web and mobile apps. */ 039 protected final String displayName; 040 041 /** A description of the field. This is not shown to the user. */ 042 protected String description; 043 044 /** 045 * Whether this field is hidden in the UI for the user and can only be set through the API 046 * instead. 047 */ 048 protected Boolean hidden; 049 050 /** 051 * A list of options for this field. This is used in combination with the `enum` and `multiSelect` 052 * field types. 053 */ 054 protected List<MetadataTemplateFieldsOptionsField> options; 055 056 /** The unique ID of the metadata template field. */ 057 protected String id; 058 059 public MetadataTemplateFieldsField( 060 MetadataTemplateFieldsTypeField type, String key, String displayName) { 061 super(); 062 this.type = new EnumWrapper<MetadataTemplateFieldsTypeField>(type); 063 this.key = key; 064 this.displayName = displayName; 065 } 066 067 public MetadataTemplateFieldsField( 068 @JsonProperty("type") EnumWrapper<MetadataTemplateFieldsTypeField> type, 069 @JsonProperty("key") String key, 070 @JsonProperty("displayName") String displayName) { 071 super(); 072 this.type = type; 073 this.key = key; 074 this.displayName = displayName; 075 } 076 077 protected MetadataTemplateFieldsField(Builder builder) { 078 super(); 079 this.type = builder.type; 080 this.key = builder.key; 081 this.displayName = builder.displayName; 082 this.description = builder.description; 083 this.hidden = builder.hidden; 084 this.options = builder.options; 085 this.id = builder.id; 086 markNullableFieldsAsSet(builder.getExplicitlySetNullableFields()); 087 } 088 089 public EnumWrapper<MetadataTemplateFieldsTypeField> getType() { 090 return type; 091 } 092 093 public String getKey() { 094 return key; 095 } 096 097 public String getDisplayName() { 098 return displayName; 099 } 100 101 public String getDescription() { 102 return description; 103 } 104 105 public Boolean getHidden() { 106 return hidden; 107 } 108 109 public List<MetadataTemplateFieldsOptionsField> getOptions() { 110 return options; 111 } 112 113 public String getId() { 114 return id; 115 } 116 117 @Override 118 public boolean equals(Object o) { 119 if (this == o) { 120 return true; 121 } 122 if (o == null || getClass() != o.getClass()) { 123 return false; 124 } 125 MetadataTemplateFieldsField casted = (MetadataTemplateFieldsField) o; 126 return Objects.equals(type, casted.type) 127 && Objects.equals(key, casted.key) 128 && Objects.equals(displayName, casted.displayName) 129 && Objects.equals(description, casted.description) 130 && Objects.equals(hidden, casted.hidden) 131 && Objects.equals(options, casted.options) 132 && Objects.equals(id, casted.id); 133 } 134 135 @Override 136 public int hashCode() { 137 return Objects.hash(type, key, displayName, description, hidden, options, id); 138 } 139 140 @Override 141 public String toString() { 142 return "MetadataTemplateFieldsField{" 143 + "type='" 144 + type 145 + '\'' 146 + ", " 147 + "key='" 148 + key 149 + '\'' 150 + ", " 151 + "displayName='" 152 + displayName 153 + '\'' 154 + ", " 155 + "description='" 156 + description 157 + '\'' 158 + ", " 159 + "hidden='" 160 + hidden 161 + '\'' 162 + ", " 163 + "options='" 164 + options 165 + '\'' 166 + ", " 167 + "id='" 168 + id 169 + '\'' 170 + "}"; 171 } 172 173 public static class Builder extends NullableFieldTracker { 174 175 protected final EnumWrapper<MetadataTemplateFieldsTypeField> type; 176 177 protected final String key; 178 179 protected final String displayName; 180 181 protected String description; 182 183 protected Boolean hidden; 184 185 protected List<MetadataTemplateFieldsOptionsField> options; 186 187 protected String id; 188 189 public Builder(MetadataTemplateFieldsTypeField type, String key, String displayName) { 190 super(); 191 this.type = new EnumWrapper<MetadataTemplateFieldsTypeField>(type); 192 this.key = key; 193 this.displayName = displayName; 194 } 195 196 public Builder( 197 EnumWrapper<MetadataTemplateFieldsTypeField> type, String key, String displayName) { 198 super(); 199 this.type = type; 200 this.key = key; 201 this.displayName = displayName; 202 } 203 204 public Builder description(String description) { 205 this.description = description; 206 return this; 207 } 208 209 public Builder hidden(Boolean hidden) { 210 this.hidden = hidden; 211 return this; 212 } 213 214 public Builder options(List<MetadataTemplateFieldsOptionsField> options) { 215 this.options = options; 216 return this; 217 } 218 219 public Builder id(String id) { 220 this.id = id; 221 return this; 222 } 223 224 public MetadataTemplateFieldsField build() { 225 return new MetadataTemplateFieldsField(this); 226 } 227 } 228}