001package com.box.sdkgen.schemas.retentionpolicyassignment; 002 003import com.box.sdkgen.internal.Nullable; 004import com.box.sdkgen.internal.NullableFieldTracker; 005import com.box.sdkgen.internal.SerializableObject; 006import com.box.sdkgen.internal.utils.DateTimeUtils; 007import com.box.sdkgen.schemas.retentionpolicymini.RetentionPolicyMini; 008import com.box.sdkgen.schemas.usermini.UserMini; 009import com.box.sdkgen.serialization.json.EnumWrapper; 010import com.fasterxml.jackson.annotation.JsonFilter; 011import com.fasterxml.jackson.annotation.JsonProperty; 012import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 013import com.fasterxml.jackson.databind.annotation.JsonSerialize; 014import java.time.OffsetDateTime; 015import java.util.List; 016import java.util.Objects; 017 018/** 019 * A retention assignment represents a rule specifying the files a retention policy retains. 020 * Assignments can retain files based on their folder or metadata, or hold all files in the 021 * enterprise. 022 */ 023@JsonFilter("nullablePropertyFilter") 024public class RetentionPolicyAssignment extends SerializableObject { 025 026 /** The unique identifier for a retention policy assignment. */ 027 protected final String id; 028 029 /** The value will always be `retention_policy_assignment`. */ 030 @JsonDeserialize( 031 using = 032 RetentionPolicyAssignmentTypeField.RetentionPolicyAssignmentTypeFieldDeserializer.class) 033 @JsonSerialize( 034 using = RetentionPolicyAssignmentTypeField.RetentionPolicyAssignmentTypeFieldSerializer.class) 035 protected EnumWrapper<RetentionPolicyAssignmentTypeField> type; 036 037 @JsonProperty("retention_policy") 038 protected RetentionPolicyMini retentionPolicy; 039 040 /** 041 * The `type` and `id` of the content that is under retention. The `type` can either be `folder` 042 * `enterprise`, or `metadata_template`. 043 */ 044 @JsonProperty("assigned_to") 045 protected RetentionPolicyAssignmentAssignedToField assignedTo; 046 047 /** 048 * An array of field objects. Values are only returned if the `assigned_to` type is 049 * `metadata_template`. Otherwise, the array is blank. 050 */ 051 @JsonProperty("filter_fields") 052 @Nullable 053 protected List<RetentionPolicyAssignmentFilterFieldsField> filterFields; 054 055 @JsonProperty("assigned_by") 056 protected UserMini assignedBy; 057 058 /** When the retention policy assignment object was created. */ 059 @JsonProperty("assigned_at") 060 @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class) 061 @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class) 062 protected OffsetDateTime assignedAt; 063 064 /** 065 * The date the retention policy assignment begins. If the `assigned_to` type is 066 * `metadata_template`, this field can be a date field's metadata attribute key id. 067 */ 068 @JsonProperty("start_date_field") 069 protected String startDateField; 070 071 public RetentionPolicyAssignment(@JsonProperty("id") String id) { 072 super(); 073 this.id = id; 074 this.type = 075 new EnumWrapper<RetentionPolicyAssignmentTypeField>( 076 RetentionPolicyAssignmentTypeField.RETENTION_POLICY_ASSIGNMENT); 077 } 078 079 protected RetentionPolicyAssignment(Builder builder) { 080 super(); 081 this.id = builder.id; 082 this.type = builder.type; 083 this.retentionPolicy = builder.retentionPolicy; 084 this.assignedTo = builder.assignedTo; 085 this.filterFields = builder.filterFields; 086 this.assignedBy = builder.assignedBy; 087 this.assignedAt = builder.assignedAt; 088 this.startDateField = builder.startDateField; 089 markNullableFieldsAsSet(builder.getExplicitlySetNullableFields()); 090 } 091 092 public String getId() { 093 return id; 094 } 095 096 public EnumWrapper<RetentionPolicyAssignmentTypeField> getType() { 097 return type; 098 } 099 100 public RetentionPolicyMini getRetentionPolicy() { 101 return retentionPolicy; 102 } 103 104 public RetentionPolicyAssignmentAssignedToField getAssignedTo() { 105 return assignedTo; 106 } 107 108 public List<RetentionPolicyAssignmentFilterFieldsField> getFilterFields() { 109 return filterFields; 110 } 111 112 public UserMini getAssignedBy() { 113 return assignedBy; 114 } 115 116 public OffsetDateTime getAssignedAt() { 117 return assignedAt; 118 } 119 120 public String getStartDateField() { 121 return startDateField; 122 } 123 124 @Override 125 public boolean equals(Object o) { 126 if (this == o) { 127 return true; 128 } 129 if (o == null || getClass() != o.getClass()) { 130 return false; 131 } 132 RetentionPolicyAssignment casted = (RetentionPolicyAssignment) o; 133 return Objects.equals(id, casted.id) 134 && Objects.equals(type, casted.type) 135 && Objects.equals(retentionPolicy, casted.retentionPolicy) 136 && Objects.equals(assignedTo, casted.assignedTo) 137 && Objects.equals(filterFields, casted.filterFields) 138 && Objects.equals(assignedBy, casted.assignedBy) 139 && Objects.equals(assignedAt, casted.assignedAt) 140 && Objects.equals(startDateField, casted.startDateField); 141 } 142 143 @Override 144 public int hashCode() { 145 return Objects.hash( 146 id, 147 type, 148 retentionPolicy, 149 assignedTo, 150 filterFields, 151 assignedBy, 152 assignedAt, 153 startDateField); 154 } 155 156 @Override 157 public String toString() { 158 return "RetentionPolicyAssignment{" 159 + "id='" 160 + id 161 + '\'' 162 + ", " 163 + "type='" 164 + type 165 + '\'' 166 + ", " 167 + "retentionPolicy='" 168 + retentionPolicy 169 + '\'' 170 + ", " 171 + "assignedTo='" 172 + assignedTo 173 + '\'' 174 + ", " 175 + "filterFields='" 176 + filterFields 177 + '\'' 178 + ", " 179 + "assignedBy='" 180 + assignedBy 181 + '\'' 182 + ", " 183 + "assignedAt='" 184 + assignedAt 185 + '\'' 186 + ", " 187 + "startDateField='" 188 + startDateField 189 + '\'' 190 + "}"; 191 } 192 193 public static class Builder extends NullableFieldTracker { 194 195 protected final String id; 196 197 protected EnumWrapper<RetentionPolicyAssignmentTypeField> type; 198 199 protected RetentionPolicyMini retentionPolicy; 200 201 protected RetentionPolicyAssignmentAssignedToField assignedTo; 202 203 protected List<RetentionPolicyAssignmentFilterFieldsField> filterFields; 204 205 protected UserMini assignedBy; 206 207 protected OffsetDateTime assignedAt; 208 209 protected String startDateField; 210 211 public Builder(String id) { 212 super(); 213 this.id = id; 214 } 215 216 public Builder type(RetentionPolicyAssignmentTypeField type) { 217 this.type = new EnumWrapper<RetentionPolicyAssignmentTypeField>(type); 218 return this; 219 } 220 221 public Builder type(EnumWrapper<RetentionPolicyAssignmentTypeField> type) { 222 this.type = type; 223 return this; 224 } 225 226 public Builder retentionPolicy(RetentionPolicyMini retentionPolicy) { 227 this.retentionPolicy = retentionPolicy; 228 return this; 229 } 230 231 public Builder assignedTo(RetentionPolicyAssignmentAssignedToField assignedTo) { 232 this.assignedTo = assignedTo; 233 return this; 234 } 235 236 public Builder filterFields(List<RetentionPolicyAssignmentFilterFieldsField> filterFields) { 237 this.filterFields = filterFields; 238 this.markNullableFieldAsSet("filter_fields"); 239 return this; 240 } 241 242 public Builder assignedBy(UserMini assignedBy) { 243 this.assignedBy = assignedBy; 244 return this; 245 } 246 247 public Builder assignedAt(OffsetDateTime assignedAt) { 248 this.assignedAt = assignedAt; 249 return this; 250 } 251 252 public Builder startDateField(String startDateField) { 253 this.startDateField = startDateField; 254 return this; 255 } 256 257 public RetentionPolicyAssignment build() { 258 if (this.type == null) { 259 this.type = 260 new EnumWrapper<RetentionPolicyAssignmentTypeField>( 261 RetentionPolicyAssignmentTypeField.RETENTION_POLICY_ASSIGNMENT); 262 } 263 return new RetentionPolicyAssignment(this); 264 } 265 } 266}