001package com.box.sdkgen.schemas.user; 002 003import com.box.sdkgen.internal.Nullable; 004import com.box.sdkgen.internal.utils.DateTimeUtils; 005import com.box.sdkgen.schemas.userbase.UserBaseTypeField; 006import com.box.sdkgen.schemas.usermini.UserMini; 007import com.box.sdkgen.serialization.json.EnumWrapper; 008import com.fasterxml.jackson.annotation.JsonFilter; 009import com.fasterxml.jackson.annotation.JsonProperty; 010import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 011import com.fasterxml.jackson.databind.annotation.JsonSerialize; 012import java.time.OffsetDateTime; 013import java.util.Objects; 014 015/** A standard representation of a user, as returned from any user API endpoints by default. */ 016@JsonFilter("nullablePropertyFilter") 017public class User extends UserMini { 018 019 /** When the user object was created. */ 020 @JsonProperty("created_at") 021 @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class) 022 @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class) 023 protected OffsetDateTime createdAt; 024 025 /** When the user object was last modified. */ 026 @JsonProperty("modified_at") 027 @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class) 028 @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class) 029 protected OffsetDateTime modifiedAt; 030 031 /** 032 * The language of the user, formatted in modified version of the [ISO 033 * 639-1](https://developer.box.com/guides/api-calls/language-codes) format. 034 */ 035 protected String language; 036 037 /** The user's timezone. */ 038 protected String timezone; 039 040 /** The user’s total available space amount in bytes. */ 041 @JsonProperty("space_amount") 042 protected Long spaceAmount; 043 044 /** The amount of space in use by the user. */ 045 @JsonProperty("space_used") 046 protected Long spaceUsed; 047 048 /** The maximum individual file size in bytes the user can have. */ 049 @JsonProperty("max_upload_size") 050 protected Long maxUploadSize; 051 052 /** The user's account status. */ 053 @JsonDeserialize(using = UserStatusField.UserStatusFieldDeserializer.class) 054 @JsonSerialize(using = UserStatusField.UserStatusFieldSerializer.class) 055 protected EnumWrapper<UserStatusField> status; 056 057 /** The user’s job title. */ 058 @JsonProperty("job_title") 059 protected String jobTitle; 060 061 /** The user’s phone number. */ 062 protected String phone; 063 064 /** The user’s address. */ 065 protected String address; 066 067 /** URL of the user’s avatar image. */ 068 @JsonProperty("avatar_url") 069 protected String avatarUrl; 070 071 /** 072 * An alternate notification email address to which email notifications are sent. When it's 073 * confirmed, this will be the email address to which notifications are sent instead of to the 074 * primary email address. 075 */ 076 @JsonProperty("notification_email") 077 @Nullable 078 protected UserNotificationEmailField notificationEmail; 079 080 public User(@JsonProperty("id") String id) { 081 super(id); 082 } 083 084 protected User(Builder builder) { 085 super(builder); 086 this.createdAt = builder.createdAt; 087 this.modifiedAt = builder.modifiedAt; 088 this.language = builder.language; 089 this.timezone = builder.timezone; 090 this.spaceAmount = builder.spaceAmount; 091 this.spaceUsed = builder.spaceUsed; 092 this.maxUploadSize = builder.maxUploadSize; 093 this.status = builder.status; 094 this.jobTitle = builder.jobTitle; 095 this.phone = builder.phone; 096 this.address = builder.address; 097 this.avatarUrl = builder.avatarUrl; 098 this.notificationEmail = builder.notificationEmail; 099 markNullableFieldsAsSet(builder.getExplicitlySetNullableFields()); 100 } 101 102 public OffsetDateTime getCreatedAt() { 103 return createdAt; 104 } 105 106 public OffsetDateTime getModifiedAt() { 107 return modifiedAt; 108 } 109 110 public String getLanguage() { 111 return language; 112 } 113 114 public String getTimezone() { 115 return timezone; 116 } 117 118 public Long getSpaceAmount() { 119 return spaceAmount; 120 } 121 122 public Long getSpaceUsed() { 123 return spaceUsed; 124 } 125 126 public Long getMaxUploadSize() { 127 return maxUploadSize; 128 } 129 130 public EnumWrapper<UserStatusField> getStatus() { 131 return status; 132 } 133 134 public String getJobTitle() { 135 return jobTitle; 136 } 137 138 public String getPhone() { 139 return phone; 140 } 141 142 public String getAddress() { 143 return address; 144 } 145 146 public String getAvatarUrl() { 147 return avatarUrl; 148 } 149 150 public UserNotificationEmailField getNotificationEmail() { 151 return notificationEmail; 152 } 153 154 @Override 155 public boolean equals(Object o) { 156 if (this == o) { 157 return true; 158 } 159 if (o == null || getClass() != o.getClass()) { 160 return false; 161 } 162 User casted = (User) o; 163 return Objects.equals(id, casted.id) 164 && Objects.equals(type, casted.type) 165 && Objects.equals(name, casted.name) 166 && Objects.equals(login, casted.login) 167 && Objects.equals(createdAt, casted.createdAt) 168 && Objects.equals(modifiedAt, casted.modifiedAt) 169 && Objects.equals(language, casted.language) 170 && Objects.equals(timezone, casted.timezone) 171 && Objects.equals(spaceAmount, casted.spaceAmount) 172 && Objects.equals(spaceUsed, casted.spaceUsed) 173 && Objects.equals(maxUploadSize, casted.maxUploadSize) 174 && Objects.equals(status, casted.status) 175 && Objects.equals(jobTitle, casted.jobTitle) 176 && Objects.equals(phone, casted.phone) 177 && Objects.equals(address, casted.address) 178 && Objects.equals(avatarUrl, casted.avatarUrl) 179 && Objects.equals(notificationEmail, casted.notificationEmail); 180 } 181 182 @Override 183 public int hashCode() { 184 return Objects.hash( 185 id, 186 type, 187 name, 188 login, 189 createdAt, 190 modifiedAt, 191 language, 192 timezone, 193 spaceAmount, 194 spaceUsed, 195 maxUploadSize, 196 status, 197 jobTitle, 198 phone, 199 address, 200 avatarUrl, 201 notificationEmail); 202 } 203 204 @Override 205 public String toString() { 206 return "User{" 207 + "id='" 208 + id 209 + '\'' 210 + ", " 211 + "type='" 212 + type 213 + '\'' 214 + ", " 215 + "name='" 216 + name 217 + '\'' 218 + ", " 219 + "login='" 220 + login 221 + '\'' 222 + ", " 223 + "createdAt='" 224 + createdAt 225 + '\'' 226 + ", " 227 + "modifiedAt='" 228 + modifiedAt 229 + '\'' 230 + ", " 231 + "language='" 232 + language 233 + '\'' 234 + ", " 235 + "timezone='" 236 + timezone 237 + '\'' 238 + ", " 239 + "spaceAmount='" 240 + spaceAmount 241 + '\'' 242 + ", " 243 + "spaceUsed='" 244 + spaceUsed 245 + '\'' 246 + ", " 247 + "maxUploadSize='" 248 + maxUploadSize 249 + '\'' 250 + ", " 251 + "status='" 252 + status 253 + '\'' 254 + ", " 255 + "jobTitle='" 256 + jobTitle 257 + '\'' 258 + ", " 259 + "phone='" 260 + phone 261 + '\'' 262 + ", " 263 + "address='" 264 + address 265 + '\'' 266 + ", " 267 + "avatarUrl='" 268 + avatarUrl 269 + '\'' 270 + ", " 271 + "notificationEmail='" 272 + notificationEmail 273 + '\'' 274 + "}"; 275 } 276 277 public static class Builder extends UserMini.Builder { 278 279 protected OffsetDateTime createdAt; 280 281 protected OffsetDateTime modifiedAt; 282 283 protected String language; 284 285 protected String timezone; 286 287 protected Long spaceAmount; 288 289 protected Long spaceUsed; 290 291 protected Long maxUploadSize; 292 293 protected EnumWrapper<UserStatusField> status; 294 295 protected String jobTitle; 296 297 protected String phone; 298 299 protected String address; 300 301 protected String avatarUrl; 302 303 protected UserNotificationEmailField notificationEmail; 304 305 public Builder(String id) { 306 super(id); 307 } 308 309 public Builder createdAt(OffsetDateTime createdAt) { 310 this.createdAt = createdAt; 311 return this; 312 } 313 314 public Builder modifiedAt(OffsetDateTime modifiedAt) { 315 this.modifiedAt = modifiedAt; 316 return this; 317 } 318 319 public Builder language(String language) { 320 this.language = language; 321 return this; 322 } 323 324 public Builder timezone(String timezone) { 325 this.timezone = timezone; 326 return this; 327 } 328 329 public Builder spaceAmount(Long spaceAmount) { 330 this.spaceAmount = spaceAmount; 331 return this; 332 } 333 334 public Builder spaceUsed(Long spaceUsed) { 335 this.spaceUsed = spaceUsed; 336 return this; 337 } 338 339 public Builder maxUploadSize(Long maxUploadSize) { 340 this.maxUploadSize = maxUploadSize; 341 return this; 342 } 343 344 public Builder status(UserStatusField status) { 345 this.status = new EnumWrapper<UserStatusField>(status); 346 return this; 347 } 348 349 public Builder status(EnumWrapper<UserStatusField> status) { 350 this.status = status; 351 return this; 352 } 353 354 public Builder jobTitle(String jobTitle) { 355 this.jobTitle = jobTitle; 356 return this; 357 } 358 359 public Builder phone(String phone) { 360 this.phone = phone; 361 return this; 362 } 363 364 public Builder address(String address) { 365 this.address = address; 366 return this; 367 } 368 369 public Builder avatarUrl(String avatarUrl) { 370 this.avatarUrl = avatarUrl; 371 return this; 372 } 373 374 public Builder notificationEmail(UserNotificationEmailField notificationEmail) { 375 this.notificationEmail = notificationEmail; 376 this.markNullableFieldAsSet("notification_email"); 377 return this; 378 } 379 380 @Override 381 public Builder type(UserBaseTypeField type) { 382 this.type = new EnumWrapper<UserBaseTypeField>(type); 383 return this; 384 } 385 386 @Override 387 public Builder type(EnumWrapper<UserBaseTypeField> type) { 388 this.type = type; 389 return this; 390 } 391 392 @Override 393 public Builder name(String name) { 394 this.name = name; 395 return this; 396 } 397 398 @Override 399 public Builder login(String login) { 400 this.login = login; 401 return this; 402 } 403 404 public User build() { 405 if (this.type == null) { 406 this.type = new EnumWrapper<UserBaseTypeField>(UserBaseTypeField.USER); 407 } 408 return new User(this); 409 } 410 } 411}