001package com.box.sdkgen.schemas.usermini; 002 003import com.box.sdkgen.schemas.userbase.UserBase; 004import com.box.sdkgen.schemas.userbase.UserBaseTypeField; 005import com.box.sdkgen.serialization.json.EnumWrapper; 006import com.fasterxml.jackson.annotation.JsonFilter; 007import com.fasterxml.jackson.annotation.JsonProperty; 008import java.util.Objects; 009 010/** A mini representation of a user, as can be returned when nested within other resources. */ 011@JsonFilter("nullablePropertyFilter") 012public class UserMini extends UserBase { 013 014 /** The display name of this user. */ 015 protected String name; 016 017 /** The primary email address of this user. */ 018 protected String login; 019 020 public UserMini(@JsonProperty("id") String id) { 021 super(id); 022 } 023 024 protected UserMini(Builder builder) { 025 super(builder); 026 this.name = builder.name; 027 this.login = builder.login; 028 markNullableFieldsAsSet(builder.getExplicitlySetNullableFields()); 029 } 030 031 public String getName() { 032 return name; 033 } 034 035 public String getLogin() { 036 return login; 037 } 038 039 @Override 040 public boolean equals(Object o) { 041 if (this == o) { 042 return true; 043 } 044 if (o == null || getClass() != o.getClass()) { 045 return false; 046 } 047 UserMini casted = (UserMini) o; 048 return Objects.equals(id, casted.id) 049 && Objects.equals(type, casted.type) 050 && Objects.equals(name, casted.name) 051 && Objects.equals(login, casted.login); 052 } 053 054 @Override 055 public int hashCode() { 056 return Objects.hash(id, type, name, login); 057 } 058 059 @Override 060 public String toString() { 061 return "UserMini{" 062 + "id='" 063 + id 064 + '\'' 065 + ", " 066 + "type='" 067 + type 068 + '\'' 069 + ", " 070 + "name='" 071 + name 072 + '\'' 073 + ", " 074 + "login='" 075 + login 076 + '\'' 077 + "}"; 078 } 079 080 public static class Builder extends UserBase.Builder { 081 082 protected String name; 083 084 protected String login; 085 086 public Builder(String id) { 087 super(id); 088 } 089 090 public Builder name(String name) { 091 this.name = name; 092 return this; 093 } 094 095 public Builder login(String login) { 096 this.login = login; 097 return this; 098 } 099 100 @Override 101 public Builder type(UserBaseTypeField type) { 102 this.type = new EnumWrapper<UserBaseTypeField>(type); 103 return this; 104 } 105 106 @Override 107 public Builder type(EnumWrapper<UserBaseTypeField> type) { 108 this.type = type; 109 return this; 110 } 111 112 public UserMini build() { 113 if (this.type == null) { 114 this.type = new EnumWrapper<UserBaseTypeField>(UserBaseTypeField.USER); 115 } 116 return new UserMini(this); 117 } 118 } 119}