001package com.box.sdkgen.schemas.appitemeventsource; 002 003import com.box.sdkgen.internal.NullableFieldTracker; 004import com.box.sdkgen.internal.SerializableObject; 005import com.box.sdkgen.schemas.groupmini.GroupMini; 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.util.Objects; 013 014/** The AppItem that triggered an event in the event stream. */ 015@JsonFilter("nullablePropertyFilter") 016public class AppItemEventSource extends SerializableObject { 017 018 /** The id of the `AppItem`. */ 019 protected final String id; 020 021 /** The type of the source that this event represents. Can only be `app_item`. */ 022 @JsonDeserialize( 023 using = AppItemEventSourceTypeField.AppItemEventSourceTypeFieldDeserializer.class) 024 @JsonSerialize(using = AppItemEventSourceTypeField.AppItemEventSourceTypeFieldSerializer.class) 025 protected EnumWrapper<AppItemEventSourceTypeField> type; 026 027 /** The type of the `AppItem`. */ 028 @JsonProperty("app_item_type") 029 protected final String appItemType; 030 031 protected UserMini user; 032 033 protected GroupMini group; 034 035 public AppItemEventSource( 036 @JsonProperty("id") String id, @JsonProperty("app_item_type") String appItemType) { 037 super(); 038 this.id = id; 039 this.appItemType = appItemType; 040 this.type = new EnumWrapper<AppItemEventSourceTypeField>(AppItemEventSourceTypeField.APP_ITEM); 041 } 042 043 protected AppItemEventSource(Builder builder) { 044 super(); 045 this.id = builder.id; 046 this.type = builder.type; 047 this.appItemType = builder.appItemType; 048 this.user = builder.user; 049 this.group = builder.group; 050 markNullableFieldsAsSet(builder.getExplicitlySetNullableFields()); 051 } 052 053 public String getId() { 054 return id; 055 } 056 057 public EnumWrapper<AppItemEventSourceTypeField> getType() { 058 return type; 059 } 060 061 public String getAppItemType() { 062 return appItemType; 063 } 064 065 public UserMini getUser() { 066 return user; 067 } 068 069 public GroupMini getGroup() { 070 return group; 071 } 072 073 @Override 074 public boolean equals(Object o) { 075 if (this == o) { 076 return true; 077 } 078 if (o == null || getClass() != o.getClass()) { 079 return false; 080 } 081 AppItemEventSource casted = (AppItemEventSource) o; 082 return Objects.equals(id, casted.id) 083 && Objects.equals(type, casted.type) 084 && Objects.equals(appItemType, casted.appItemType) 085 && Objects.equals(user, casted.user) 086 && Objects.equals(group, casted.group); 087 } 088 089 @Override 090 public int hashCode() { 091 return Objects.hash(id, type, appItemType, user, group); 092 } 093 094 @Override 095 public String toString() { 096 return "AppItemEventSource{" 097 + "id='" 098 + id 099 + '\'' 100 + ", " 101 + "type='" 102 + type 103 + '\'' 104 + ", " 105 + "appItemType='" 106 + appItemType 107 + '\'' 108 + ", " 109 + "user='" 110 + user 111 + '\'' 112 + ", " 113 + "group='" 114 + group 115 + '\'' 116 + "}"; 117 } 118 119 public static class Builder extends NullableFieldTracker { 120 121 protected final String id; 122 123 protected EnumWrapper<AppItemEventSourceTypeField> type; 124 125 protected final String appItemType; 126 127 protected UserMini user; 128 129 protected GroupMini group; 130 131 public Builder(String id, String appItemType) { 132 super(); 133 this.id = id; 134 this.appItemType = appItemType; 135 } 136 137 public Builder type(AppItemEventSourceTypeField type) { 138 this.type = new EnumWrapper<AppItemEventSourceTypeField>(type); 139 return this; 140 } 141 142 public Builder type(EnumWrapper<AppItemEventSourceTypeField> type) { 143 this.type = type; 144 return this; 145 } 146 147 public Builder user(UserMini user) { 148 this.user = user; 149 return this; 150 } 151 152 public Builder group(GroupMini group) { 153 this.group = group; 154 return this; 155 } 156 157 public AppItemEventSource build() { 158 if (this.type == null) { 159 this.type = 160 new EnumWrapper<AppItemEventSourceTypeField>(AppItemEventSourceTypeField.APP_ITEM); 161 } 162 return new AppItemEventSource(this); 163 } 164 } 165}