001package com.box.sdkgen.schemas.completionrulevariable; 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.Objects; 011 012/** 013 * A completion rule object. Determines if an action should be completed by all or any assignees. 014 */ 015@JsonFilter("nullablePropertyFilter") 016public class CompletionRuleVariable extends SerializableObject { 017 018 /** Completion Rule object type. */ 019 @JsonDeserialize( 020 using = CompletionRuleVariableTypeField.CompletionRuleVariableTypeFieldDeserializer.class) 021 @JsonSerialize( 022 using = CompletionRuleVariableTypeField.CompletionRuleVariableTypeFieldSerializer.class) 023 protected EnumWrapper<CompletionRuleVariableTypeField> type; 024 025 /** Variable type for the Completion Rule object. */ 026 @JsonDeserialize( 027 using = 028 CompletionRuleVariableVariableTypeField 029 .CompletionRuleVariableVariableTypeFieldDeserializer.class) 030 @JsonSerialize( 031 using = 032 CompletionRuleVariableVariableTypeField.CompletionRuleVariableVariableTypeFieldSerializer 033 .class) 034 @JsonProperty("variable_type") 035 protected EnumWrapper<CompletionRuleVariableVariableTypeField> variableType; 036 037 /** Variable values for a completion rule. */ 038 @JsonDeserialize( 039 using = 040 CompletionRuleVariableVariableValueField 041 .CompletionRuleVariableVariableValueFieldDeserializer.class) 042 @JsonSerialize( 043 using = 044 CompletionRuleVariableVariableValueField 045 .CompletionRuleVariableVariableValueFieldSerializer.class) 046 @JsonProperty("variable_value") 047 protected final EnumWrapper<CompletionRuleVariableVariableValueField> variableValue; 048 049 public CompletionRuleVariable(CompletionRuleVariableVariableValueField variableValue) { 050 super(); 051 this.variableValue = new EnumWrapper<CompletionRuleVariableVariableValueField>(variableValue); 052 this.type = 053 new EnumWrapper<CompletionRuleVariableTypeField>(CompletionRuleVariableTypeField.VARIABLE); 054 this.variableType = 055 new EnumWrapper<CompletionRuleVariableVariableTypeField>( 056 CompletionRuleVariableVariableTypeField.TASK_COMPLETION_RULE); 057 } 058 059 public CompletionRuleVariable( 060 @JsonProperty("variable_value") 061 EnumWrapper<CompletionRuleVariableVariableValueField> variableValue) { 062 super(); 063 this.variableValue = variableValue; 064 this.type = 065 new EnumWrapper<CompletionRuleVariableTypeField>(CompletionRuleVariableTypeField.VARIABLE); 066 this.variableType = 067 new EnumWrapper<CompletionRuleVariableVariableTypeField>( 068 CompletionRuleVariableVariableTypeField.TASK_COMPLETION_RULE); 069 } 070 071 protected CompletionRuleVariable(Builder builder) { 072 super(); 073 this.type = builder.type; 074 this.variableType = builder.variableType; 075 this.variableValue = builder.variableValue; 076 markNullableFieldsAsSet(builder.getExplicitlySetNullableFields()); 077 } 078 079 public EnumWrapper<CompletionRuleVariableTypeField> getType() { 080 return type; 081 } 082 083 public EnumWrapper<CompletionRuleVariableVariableTypeField> getVariableType() { 084 return variableType; 085 } 086 087 public EnumWrapper<CompletionRuleVariableVariableValueField> getVariableValue() { 088 return variableValue; 089 } 090 091 @Override 092 public boolean equals(Object o) { 093 if (this == o) { 094 return true; 095 } 096 if (o == null || getClass() != o.getClass()) { 097 return false; 098 } 099 CompletionRuleVariable casted = (CompletionRuleVariable) o; 100 return Objects.equals(type, casted.type) 101 && Objects.equals(variableType, casted.variableType) 102 && Objects.equals(variableValue, casted.variableValue); 103 } 104 105 @Override 106 public int hashCode() { 107 return Objects.hash(type, variableType, variableValue); 108 } 109 110 @Override 111 public String toString() { 112 return "CompletionRuleVariable{" 113 + "type='" 114 + type 115 + '\'' 116 + ", " 117 + "variableType='" 118 + variableType 119 + '\'' 120 + ", " 121 + "variableValue='" 122 + variableValue 123 + '\'' 124 + "}"; 125 } 126 127 public static class Builder extends NullableFieldTracker { 128 129 protected EnumWrapper<CompletionRuleVariableTypeField> type; 130 131 protected EnumWrapper<CompletionRuleVariableVariableTypeField> variableType; 132 133 protected final EnumWrapper<CompletionRuleVariableVariableValueField> variableValue; 134 135 public Builder(CompletionRuleVariableVariableValueField variableValue) { 136 super(); 137 this.variableValue = new EnumWrapper<CompletionRuleVariableVariableValueField>(variableValue); 138 } 139 140 public Builder(EnumWrapper<CompletionRuleVariableVariableValueField> variableValue) { 141 super(); 142 this.variableValue = variableValue; 143 } 144 145 public Builder type(CompletionRuleVariableTypeField type) { 146 this.type = new EnumWrapper<CompletionRuleVariableTypeField>(type); 147 return this; 148 } 149 150 public Builder type(EnumWrapper<CompletionRuleVariableTypeField> type) { 151 this.type = type; 152 return this; 153 } 154 155 public Builder variableType(CompletionRuleVariableVariableTypeField variableType) { 156 this.variableType = new EnumWrapper<CompletionRuleVariableVariableTypeField>(variableType); 157 return this; 158 } 159 160 public Builder variableType(EnumWrapper<CompletionRuleVariableVariableTypeField> variableType) { 161 this.variableType = variableType; 162 return this; 163 } 164 165 public CompletionRuleVariable build() { 166 if (this.type == null) { 167 this.type = 168 new EnumWrapper<CompletionRuleVariableTypeField>( 169 CompletionRuleVariableTypeField.VARIABLE); 170 } 171 if (this.variableType == null) { 172 this.variableType = 173 new EnumWrapper<CompletionRuleVariableVariableTypeField>( 174 CompletionRuleVariableVariableTypeField.TASK_COMPLETION_RULE); 175 } 176 return new CompletionRuleVariable(this); 177 } 178 } 179}