001package com.box.sdkgen.schemas.userbase; 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.Objects; 011 012/** A mini representation of a user, used when nested within another resource. */ 013@JsonFilter("nullablePropertyFilter") 014public class UserBase extends SerializableObject { 015 016 /** The unique identifier for this user. */ 017 protected final String id; 018 019 /** The value will always be `user`. */ 020 @JsonDeserialize(using = UserBaseTypeField.UserBaseTypeFieldDeserializer.class) 021 @JsonSerialize(using = UserBaseTypeField.UserBaseTypeFieldSerializer.class) 022 protected EnumWrapper<UserBaseTypeField> type; 023 024 public UserBase(@JsonProperty("id") String id) { 025 super(); 026 this.id = id; 027 this.type = new EnumWrapper<UserBaseTypeField>(UserBaseTypeField.USER); 028 } 029 030 protected UserBase(Builder builder) { 031 super(); 032 this.id = builder.id; 033 this.type = builder.type; 034 markNullableFieldsAsSet(builder.getExplicitlySetNullableFields()); 035 } 036 037 public String getId() { 038 return id; 039 } 040 041 public EnumWrapper<UserBaseTypeField> getType() { 042 return type; 043 } 044 045 @Override 046 public boolean equals(Object o) { 047 if (this == o) { 048 return true; 049 } 050 if (o == null || getClass() != o.getClass()) { 051 return false; 052 } 053 UserBase casted = (UserBase) o; 054 return Objects.equals(id, casted.id) && Objects.equals(type, casted.type); 055 } 056 057 @Override 058 public int hashCode() { 059 return Objects.hash(id, type); 060 } 061 062 @Override 063 public String toString() { 064 return "UserBase{" + "id='" + id + '\'' + ", " + "type='" + type + '\'' + "}"; 065 } 066 067 public static class Builder extends NullableFieldTracker { 068 069 protected final String id; 070 071 protected EnumWrapper<UserBaseTypeField> type; 072 073 public Builder(String id) { 074 super(); 075 this.id = id; 076 } 077 078 public Builder type(UserBaseTypeField type) { 079 this.type = new EnumWrapper<UserBaseTypeField>(type); 080 return this; 081 } 082 083 public Builder type(EnumWrapper<UserBaseTypeField> type) { 084 this.type = type; 085 return this; 086 } 087 088 public UserBase build() { 089 if (this.type == null) { 090 this.type = new EnumWrapper<UserBaseTypeField>(UserBaseTypeField.USER); 091 } 092 return new UserBase(this); 093 } 094 } 095}