001package com.box.sdkgen.schemas.resourcescope; 002 003import com.box.sdkgen.internal.NullableFieldTracker; 004import com.box.sdkgen.internal.SerializableObject; 005import com.box.sdkgen.schemas.filemini.FileMini; 006import com.box.sdkgen.schemas.foldermini.FolderMini; 007import com.box.sdkgen.schemas.resource.Resource; 008import com.box.sdkgen.serialization.json.EnumWrapper; 009import com.fasterxml.jackson.annotation.JsonFilter; 010import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 011import com.fasterxml.jackson.databind.annotation.JsonSerialize; 012import java.util.Objects; 013 014/** 015 * A relation between a resource (file or folder) and the scopes for which the resource can be 016 * accessed. 017 */ 018@JsonFilter("nullablePropertyFilter") 019public class ResourceScope extends SerializableObject { 020 021 /** The scopes for the resource access. */ 022 @JsonDeserialize(using = ResourceScopeScopeField.ResourceScopeScopeFieldDeserializer.class) 023 @JsonSerialize(using = ResourceScopeScopeField.ResourceScopeScopeFieldSerializer.class) 024 protected EnumWrapper<ResourceScopeScopeField> scope; 025 026 protected Resource object; 027 028 public ResourceScope() { 029 super(); 030 } 031 032 protected ResourceScope(Builder builder) { 033 super(); 034 this.scope = builder.scope; 035 this.object = builder.object; 036 markNullableFieldsAsSet(builder.getExplicitlySetNullableFields()); 037 } 038 039 public EnumWrapper<ResourceScopeScopeField> getScope() { 040 return scope; 041 } 042 043 public Resource getObject() { 044 return object; 045 } 046 047 @Override 048 public boolean equals(Object o) { 049 if (this == o) { 050 return true; 051 } 052 if (o == null || getClass() != o.getClass()) { 053 return false; 054 } 055 ResourceScope casted = (ResourceScope) o; 056 return Objects.equals(scope, casted.scope) && Objects.equals(object, casted.object); 057 } 058 059 @Override 060 public int hashCode() { 061 return Objects.hash(scope, object); 062 } 063 064 @Override 065 public String toString() { 066 return "ResourceScope{" + "scope='" + scope + '\'' + ", " + "object='" + object + '\'' + "}"; 067 } 068 069 public static class Builder extends NullableFieldTracker { 070 071 protected EnumWrapper<ResourceScopeScopeField> scope; 072 073 protected Resource object; 074 075 public Builder scope(ResourceScopeScopeField scope) { 076 this.scope = new EnumWrapper<ResourceScopeScopeField>(scope); 077 return this; 078 } 079 080 public Builder scope(EnumWrapper<ResourceScopeScopeField> scope) { 081 this.scope = scope; 082 return this; 083 } 084 085 public Builder object(FolderMini object) { 086 this.object = new Resource(object); 087 return this; 088 } 089 090 public Builder object(FileMini object) { 091 this.object = new Resource(object); 092 return this; 093 } 094 095 public Builder object(Resource object) { 096 this.object = object; 097 return this; 098 } 099 100 public ResourceScope build() { 101 return new ResourceScope(this); 102 } 103 } 104}