001package com.box.sdkgen.schemas.folderlock;
002
003import com.box.sdkgen.internal.NullableFieldTracker;
004import com.box.sdkgen.internal.SerializableObject;
005import com.box.sdkgen.internal.utils.DateTimeUtils;
006import com.box.sdkgen.schemas.foldermini.FolderMini;
007import com.box.sdkgen.schemas.userbase.UserBase;
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.time.OffsetDateTime;
013import java.util.Objects;
014
015/**
016 * Folder locks define access restrictions placed by folder owners to prevent specific folders from
017 * being moved or deleted.
018 */
019@JsonFilter("nullablePropertyFilter")
020public class FolderLock extends SerializableObject {
021
022  protected FolderMini folder;
023
024  /** The unique identifier for this folder lock. */
025  protected String id;
026
027  /** The object type, always `folder_lock`. */
028  protected String type;
029
030  @JsonProperty("created_by")
031  protected UserBase createdBy;
032
033  /** When the folder lock object was created. */
034  @JsonProperty("created_at")
035  @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class)
036  @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class)
037  protected OffsetDateTime createdAt;
038
039  /**
040   * The operations that have been locked. Currently the `move` and `delete` operations cannot be
041   * locked separately, and both need to be set to `true`.
042   */
043  @JsonProperty("locked_operations")
044  protected FolderLockLockedOperationsField lockedOperations;
045
046  /** The lock type, always `freeze`. */
047  @JsonProperty("lock_type")
048  protected String lockType;
049
050  public FolderLock() {
051    super();
052  }
053
054  protected FolderLock(Builder builder) {
055    super();
056    this.folder = builder.folder;
057    this.id = builder.id;
058    this.type = builder.type;
059    this.createdBy = builder.createdBy;
060    this.createdAt = builder.createdAt;
061    this.lockedOperations = builder.lockedOperations;
062    this.lockType = builder.lockType;
063    markNullableFieldsAsSet(builder.getExplicitlySetNullableFields());
064  }
065
066  public FolderMini getFolder() {
067    return folder;
068  }
069
070  public String getId() {
071    return id;
072  }
073
074  public String getType() {
075    return type;
076  }
077
078  public UserBase getCreatedBy() {
079    return createdBy;
080  }
081
082  public OffsetDateTime getCreatedAt() {
083    return createdAt;
084  }
085
086  public FolderLockLockedOperationsField getLockedOperations() {
087    return lockedOperations;
088  }
089
090  public String getLockType() {
091    return lockType;
092  }
093
094  @Override
095  public boolean equals(Object o) {
096    if (this == o) {
097      return true;
098    }
099    if (o == null || getClass() != o.getClass()) {
100      return false;
101    }
102    FolderLock casted = (FolderLock) o;
103    return Objects.equals(folder, casted.folder)
104        && Objects.equals(id, casted.id)
105        && Objects.equals(type, casted.type)
106        && Objects.equals(createdBy, casted.createdBy)
107        && Objects.equals(createdAt, casted.createdAt)
108        && Objects.equals(lockedOperations, casted.lockedOperations)
109        && Objects.equals(lockType, casted.lockType);
110  }
111
112  @Override
113  public int hashCode() {
114    return Objects.hash(folder, id, type, createdBy, createdAt, lockedOperations, lockType);
115  }
116
117  @Override
118  public String toString() {
119    return "FolderLock{"
120        + "folder='"
121        + folder
122        + '\''
123        + ", "
124        + "id='"
125        + id
126        + '\''
127        + ", "
128        + "type='"
129        + type
130        + '\''
131        + ", "
132        + "createdBy='"
133        + createdBy
134        + '\''
135        + ", "
136        + "createdAt='"
137        + createdAt
138        + '\''
139        + ", "
140        + "lockedOperations='"
141        + lockedOperations
142        + '\''
143        + ", "
144        + "lockType='"
145        + lockType
146        + '\''
147        + "}";
148  }
149
150  public static class Builder extends NullableFieldTracker {
151
152    protected FolderMini folder;
153
154    protected String id;
155
156    protected String type;
157
158    protected UserBase createdBy;
159
160    protected OffsetDateTime createdAt;
161
162    protected FolderLockLockedOperationsField lockedOperations;
163
164    protected String lockType;
165
166    public Builder folder(FolderMini folder) {
167      this.folder = folder;
168      return this;
169    }
170
171    public Builder id(String id) {
172      this.id = id;
173      return this;
174    }
175
176    public Builder type(String type) {
177      this.type = type;
178      return this;
179    }
180
181    public Builder createdBy(UserBase createdBy) {
182      this.createdBy = createdBy;
183      return this;
184    }
185
186    public Builder createdAt(OffsetDateTime createdAt) {
187      this.createdAt = createdAt;
188      return this;
189    }
190
191    public Builder lockedOperations(FolderLockLockedOperationsField lockedOperations) {
192      this.lockedOperations = lockedOperations;
193      return this;
194    }
195
196    public Builder lockType(String lockType) {
197      this.lockType = lockType;
198      return this;
199    }
200
201    public FolderLock build() {
202      return new FolderLock(this);
203    }
204  }
205}