001package com.box.sdkgen.schemas.eventsource; 002 003import com.box.sdkgen.internal.Nullable; 004import com.box.sdkgen.internal.NullableFieldTracker; 005import com.box.sdkgen.internal.SerializableObject; 006import com.box.sdkgen.schemas.foldermini.FolderMini; 007import com.box.sdkgen.schemas.usermini.UserMini; 008import com.box.sdkgen.serialization.json.EnumWrapper; 009import com.fasterxml.jackson.annotation.JsonFilter; 010import com.fasterxml.jackson.annotation.JsonProperty; 011import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 012import com.fasterxml.jackson.databind.annotation.JsonSerialize; 013import java.util.Objects; 014 015/** The source file or folder that triggered an event in the event stream. */ 016@JsonFilter("nullablePropertyFilter") 017public class EventSource extends SerializableObject { 018 019 /** The type of the item that the event represents. Can be `file` or `folder`. */ 020 @JsonDeserialize(using = EventSourceItemTypeField.EventSourceItemTypeFieldDeserializer.class) 021 @JsonSerialize(using = EventSourceItemTypeField.EventSourceItemTypeFieldSerializer.class) 022 @JsonProperty("item_type") 023 protected final EnumWrapper<EventSourceItemTypeField> itemType; 024 025 /** The unique identifier that represents the item. */ 026 @JsonProperty("item_id") 027 protected final String itemId; 028 029 /** The name of the item. */ 030 @JsonProperty("item_name") 031 protected final String itemName; 032 033 /** 034 * The object containing classification information for the item that triggered the event. This 035 * field will not appear if the item does not have a classification set. 036 */ 037 protected EventSourceClassificationField classification; 038 039 @Nullable protected FolderMini parent; 040 041 @JsonProperty("owned_by") 042 protected UserMini ownedBy; 043 044 public EventSource(EventSourceItemTypeField itemType, String itemId, String itemName) { 045 super(); 046 this.itemType = new EnumWrapper<EventSourceItemTypeField>(itemType); 047 this.itemId = itemId; 048 this.itemName = itemName; 049 } 050 051 public EventSource( 052 @JsonProperty("item_type") EnumWrapper<EventSourceItemTypeField> itemType, 053 @JsonProperty("item_id") String itemId, 054 @JsonProperty("item_name") String itemName) { 055 super(); 056 this.itemType = itemType; 057 this.itemId = itemId; 058 this.itemName = itemName; 059 } 060 061 protected EventSource(Builder builder) { 062 super(); 063 this.itemType = builder.itemType; 064 this.itemId = builder.itemId; 065 this.itemName = builder.itemName; 066 this.classification = builder.classification; 067 this.parent = builder.parent; 068 this.ownedBy = builder.ownedBy; 069 markNullableFieldsAsSet(builder.getExplicitlySetNullableFields()); 070 } 071 072 public EnumWrapper<EventSourceItemTypeField> getItemType() { 073 return itemType; 074 } 075 076 public String getItemId() { 077 return itemId; 078 } 079 080 public String getItemName() { 081 return itemName; 082 } 083 084 public EventSourceClassificationField getClassification() { 085 return classification; 086 } 087 088 public FolderMini getParent() { 089 return parent; 090 } 091 092 public UserMini getOwnedBy() { 093 return ownedBy; 094 } 095 096 @Override 097 public boolean equals(Object o) { 098 if (this == o) { 099 return true; 100 } 101 if (o == null || getClass() != o.getClass()) { 102 return false; 103 } 104 EventSource casted = (EventSource) o; 105 return Objects.equals(itemType, casted.itemType) 106 && Objects.equals(itemId, casted.itemId) 107 && Objects.equals(itemName, casted.itemName) 108 && Objects.equals(classification, casted.classification) 109 && Objects.equals(parent, casted.parent) 110 && Objects.equals(ownedBy, casted.ownedBy); 111 } 112 113 @Override 114 public int hashCode() { 115 return Objects.hash(itemType, itemId, itemName, classification, parent, ownedBy); 116 } 117 118 @Override 119 public String toString() { 120 return "EventSource{" 121 + "itemType='" 122 + itemType 123 + '\'' 124 + ", " 125 + "itemId='" 126 + itemId 127 + '\'' 128 + ", " 129 + "itemName='" 130 + itemName 131 + '\'' 132 + ", " 133 + "classification='" 134 + classification 135 + '\'' 136 + ", " 137 + "parent='" 138 + parent 139 + '\'' 140 + ", " 141 + "ownedBy='" 142 + ownedBy 143 + '\'' 144 + "}"; 145 } 146 147 public static class Builder extends NullableFieldTracker { 148 149 protected final EnumWrapper<EventSourceItemTypeField> itemType; 150 151 protected final String itemId; 152 153 protected final String itemName; 154 155 protected EventSourceClassificationField classification; 156 157 protected FolderMini parent; 158 159 protected UserMini ownedBy; 160 161 public Builder(EventSourceItemTypeField itemType, String itemId, String itemName) { 162 super(); 163 this.itemType = new EnumWrapper<EventSourceItemTypeField>(itemType); 164 this.itemId = itemId; 165 this.itemName = itemName; 166 } 167 168 public Builder(EnumWrapper<EventSourceItemTypeField> itemType, String itemId, String itemName) { 169 super(); 170 this.itemType = itemType; 171 this.itemId = itemId; 172 this.itemName = itemName; 173 } 174 175 public Builder classification(EventSourceClassificationField classification) { 176 this.classification = classification; 177 return this; 178 } 179 180 public Builder parent(FolderMini parent) { 181 this.parent = parent; 182 this.markNullableFieldAsSet("parent"); 183 return this; 184 } 185 186 public Builder ownedBy(UserMini ownedBy) { 187 this.ownedBy = ownedBy; 188 return this; 189 } 190 191 public EventSource build() { 192 return new EventSource(this); 193 } 194 } 195}