001package com.box.sdkgen.schemas.collaboratorvariable; 002 003import com.box.sdkgen.internal.NullableFieldTracker; 004import com.box.sdkgen.internal.SerializableObject; 005import com.box.sdkgen.serialization.json.EnumWrapper; 006import com.fasterxml.jackson.annotation.JsonFilter; 007import com.fasterxml.jackson.annotation.JsonProperty; 008import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 009import com.fasterxml.jackson.databind.annotation.JsonSerialize; 010import java.util.List; 011import java.util.Objects; 012 013/** 014 * A collaborator object. Allows to specify a list of user ID's that are affected by the workflow 015 * result. 016 */ 017@JsonFilter("nullablePropertyFilter") 018public class CollaboratorVariable extends SerializableObject { 019 020 /** Collaborator object type. */ 021 @JsonDeserialize( 022 using = CollaboratorVariableTypeField.CollaboratorVariableTypeFieldDeserializer.class) 023 @JsonSerialize( 024 using = CollaboratorVariableTypeField.CollaboratorVariableTypeFieldSerializer.class) 025 protected EnumWrapper<CollaboratorVariableTypeField> type; 026 027 /** Variable type for the Collaborator object. */ 028 @JsonDeserialize( 029 using = 030 CollaboratorVariableVariableTypeField.CollaboratorVariableVariableTypeFieldDeserializer 031 .class) 032 @JsonSerialize( 033 using = 034 CollaboratorVariableVariableTypeField.CollaboratorVariableVariableTypeFieldSerializer 035 .class) 036 @JsonProperty("variable_type") 037 protected EnumWrapper<CollaboratorVariableVariableTypeField> variableType; 038 039 /** A list of user IDs. */ 040 @JsonProperty("variable_value") 041 protected final List<CollaboratorVariableVariableValueField> variableValue; 042 043 public CollaboratorVariable( 044 @JsonProperty("variable_value") List<CollaboratorVariableVariableValueField> variableValue) { 045 super(); 046 this.variableValue = variableValue; 047 this.type = 048 new EnumWrapper<CollaboratorVariableTypeField>(CollaboratorVariableTypeField.VARIABLE); 049 this.variableType = 050 new EnumWrapper<CollaboratorVariableVariableTypeField>( 051 CollaboratorVariableVariableTypeField.USER_LIST); 052 } 053 054 protected CollaboratorVariable(Builder builder) { 055 super(); 056 this.type = builder.type; 057 this.variableType = builder.variableType; 058 this.variableValue = builder.variableValue; 059 markNullableFieldsAsSet(builder.getExplicitlySetNullableFields()); 060 } 061 062 public EnumWrapper<CollaboratorVariableTypeField> getType() { 063 return type; 064 } 065 066 public EnumWrapper<CollaboratorVariableVariableTypeField> getVariableType() { 067 return variableType; 068 } 069 070 public List<CollaboratorVariableVariableValueField> getVariableValue() { 071 return variableValue; 072 } 073 074 @Override 075 public boolean equals(Object o) { 076 if (this == o) { 077 return true; 078 } 079 if (o == null || getClass() != o.getClass()) { 080 return false; 081 } 082 CollaboratorVariable casted = (CollaboratorVariable) o; 083 return Objects.equals(type, casted.type) 084 && Objects.equals(variableType, casted.variableType) 085 && Objects.equals(variableValue, casted.variableValue); 086 } 087 088 @Override 089 public int hashCode() { 090 return Objects.hash(type, variableType, variableValue); 091 } 092 093 @Override 094 public String toString() { 095 return "CollaboratorVariable{" 096 + "type='" 097 + type 098 + '\'' 099 + ", " 100 + "variableType='" 101 + variableType 102 + '\'' 103 + ", " 104 + "variableValue='" 105 + variableValue 106 + '\'' 107 + "}"; 108 } 109 110 public static class Builder extends NullableFieldTracker { 111 112 protected EnumWrapper<CollaboratorVariableTypeField> type; 113 114 protected EnumWrapper<CollaboratorVariableVariableTypeField> variableType; 115 116 protected final List<CollaboratorVariableVariableValueField> variableValue; 117 118 public Builder(List<CollaboratorVariableVariableValueField> variableValue) { 119 super(); 120 this.variableValue = variableValue; 121 } 122 123 public Builder type(CollaboratorVariableTypeField type) { 124 this.type = new EnumWrapper<CollaboratorVariableTypeField>(type); 125 return this; 126 } 127 128 public Builder type(EnumWrapper<CollaboratorVariableTypeField> type) { 129 this.type = type; 130 return this; 131 } 132 133 public Builder variableType(CollaboratorVariableVariableTypeField variableType) { 134 this.variableType = new EnumWrapper<CollaboratorVariableVariableTypeField>(variableType); 135 return this; 136 } 137 138 public Builder variableType(EnumWrapper<CollaboratorVariableVariableTypeField> variableType) { 139 this.variableType = variableType; 140 return this; 141 } 142 143 public CollaboratorVariable build() { 144 if (this.type == null) { 145 this.type = 146 new EnumWrapper<CollaboratorVariableTypeField>(CollaboratorVariableTypeField.VARIABLE); 147 } 148 if (this.variableType == null) { 149 this.variableType = 150 new EnumWrapper<CollaboratorVariableVariableTypeField>( 151 CollaboratorVariableVariableTypeField.USER_LIST); 152 } 153 return new CollaboratorVariable(this); 154 } 155 } 156}