Re-sync with internal repository
[hiphop-php.git] / third-party / thrift / src / thrift / compiler / test / fixtures / inject_metadata_fields / gen-javadeprecated / Fields.java
blob986f508fdd335f04226c6f7816f7b52f85f44697
1 /**
2 * Autogenerated by Thrift
4 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5 * @generated
6 */
7 import java.util.List;
8 import java.util.ArrayList;
9 import java.util.Map;
10 import java.util.HashMap;
11 import java.util.Set;
12 import java.util.HashSet;
13 import java.util.Collections;
14 import java.util.BitSet;
15 import java.util.Arrays;
16 import com.facebook.thrift.*;
17 import com.facebook.thrift.annotations.*;
18 import com.facebook.thrift.async.*;
19 import com.facebook.thrift.meta_data.*;
20 import com.facebook.thrift.server.*;
21 import com.facebook.thrift.transport.*;
22 import com.facebook.thrift.protocol.*;
24 @SuppressWarnings({ "unused", "serial" })
25 public class Fields implements TBase, java.io.Serializable, Cloneable, Comparable<Fields> {
26 private static final TStruct STRUCT_DESC = new TStruct("Fields");
27 private static final TField INJECTED_FIELD_FIELD_DESC = new TField("injected_field", TType.STRING, (short)100);
29 public String injected_field;
30 public static final int INJECTED_FIELD = 100;
32 // isset id assignments
34 public static final Map<Integer, FieldMetaData> metaDataMap;
36 static {
37 Map<Integer, FieldMetaData> tmpMetaDataMap = new HashMap<Integer, FieldMetaData>();
38 tmpMetaDataMap.put(INJECTED_FIELD, new FieldMetaData("injected_field", TFieldRequirementType.DEFAULT,
39 new FieldValueMetaData(TType.STRING)));
40 metaDataMap = Collections.unmodifiableMap(tmpMetaDataMap);
43 static {
44 FieldMetaData.addStructMetaDataMap(Fields.class, metaDataMap);
47 public Fields() {
50 public Fields(
51 String injected_field) {
52 this();
53 this.injected_field = injected_field;
56 public static class Builder {
57 private String injected_field;
59 public Builder() {
62 public Builder setInjected_field(final String injected_field) {
63 this.injected_field = injected_field;
64 return this;
67 public Fields build() {
68 Fields result = new Fields();
69 result.setInjected_field(this.injected_field);
70 return result;
74 public static Builder builder() {
75 return new Builder();
78 /**
79 * Performs a deep copy on <i>other</i>.
81 public Fields(Fields other) {
82 if (other.isSetInjected_field()) {
83 this.injected_field = TBaseHelper.deepCopy(other.injected_field);
87 public Fields deepCopy() {
88 return new Fields(this);
91 public String getInjected_field() {
92 return this.injected_field;
95 public Fields setInjected_field(String injected_field) {
96 this.injected_field = injected_field;
97 return this;
100 public void unsetInjected_field() {
101 this.injected_field = null;
104 // Returns true if field injected_field is set (has been assigned a value) and false otherwise
105 public boolean isSetInjected_field() {
106 return this.injected_field != null;
109 public void setInjected_fieldIsSet(boolean __value) {
110 if (!__value) {
111 this.injected_field = null;
115 public void setFieldValue(int fieldID, Object __value) {
116 switch (fieldID) {
117 case INJECTED_FIELD:
118 if (__value == null) {
119 unsetInjected_field();
120 } else {
121 setInjected_field((String)__value);
123 break;
125 default:
126 throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
130 public Object getFieldValue(int fieldID) {
131 switch (fieldID) {
132 case INJECTED_FIELD:
133 return getInjected_field();
135 default:
136 throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
140 @Override
141 public boolean equals(Object _that) {
142 if (_that == null)
143 return false;
144 if (this == _that)
145 return true;
146 if (!(_that instanceof Fields))
147 return false;
148 Fields that = (Fields)_that;
150 if (!TBaseHelper.equalsNobinary(this.isSetInjected_field(), that.isSetInjected_field(), this.injected_field, that.injected_field)) { return false; }
152 return true;
155 @Override
156 public int hashCode() {
157 return Arrays.deepHashCode(new Object[] {injected_field});
160 @Override
161 public int compareTo(Fields other) {
162 if (other == null) {
163 // See java.lang.Comparable docs
164 throw new NullPointerException();
167 if (other == this) {
168 return 0;
170 int lastComparison = 0;
172 lastComparison = Boolean.valueOf(isSetInjected_field()).compareTo(other.isSetInjected_field());
173 if (lastComparison != 0) {
174 return lastComparison;
176 lastComparison = TBaseHelper.compareTo(injected_field, other.injected_field);
177 if (lastComparison != 0) {
178 return lastComparison;
180 return 0;
183 public void read(TProtocol iprot) throws TException {
184 TField __field;
185 iprot.readStructBegin(metaDataMap);
186 while (true)
188 __field = iprot.readFieldBegin();
189 if (__field.type == TType.STOP) {
190 break;
192 switch (__field.id)
194 case INJECTED_FIELD:
195 if (__field.type == TType.STRING) {
196 this.injected_field = iprot.readString();
197 } else {
198 TProtocolUtil.skip(iprot, __field.type);
200 break;
201 default:
202 TProtocolUtil.skip(iprot, __field.type);
203 break;
205 iprot.readFieldEnd();
207 iprot.readStructEnd();
210 // check for required fields of primitive type, which can't be checked in the validate method
211 validate();
214 public void write(TProtocol oprot) throws TException {
215 validate();
217 oprot.writeStructBegin(STRUCT_DESC);
218 if (this.injected_field != null) {
219 oprot.writeFieldBegin(INJECTED_FIELD_FIELD_DESC);
220 oprot.writeString(this.injected_field);
221 oprot.writeFieldEnd();
223 oprot.writeFieldStop();
224 oprot.writeStructEnd();
227 @Override
228 public String toString() {
229 return toString(1, true);
232 @Override
233 public String toString(int indent, boolean prettyPrint) {
234 String indentStr = prettyPrint ? TBaseHelper.getIndentedString(indent) : "";
235 String newLine = prettyPrint ? "\n" : "";
236 String space = prettyPrint ? " " : "";
237 StringBuilder sb = new StringBuilder("Fields");
238 sb.append(space);
239 sb.append("(");
240 sb.append(newLine);
241 boolean first = true;
243 sb.append(indentStr);
244 sb.append("injected_field");
245 sb.append(space);
246 sb.append(":").append(space);
247 if (this.getInjected_field() == null) {
248 sb.append("null");
249 } else {
250 sb.append(TBaseHelper.toString(this.getInjected_field(), indent + 1, prettyPrint));
252 first = false;
253 sb.append(newLine + TBaseHelper.reduceIndent(indentStr));
254 sb.append(")");
255 return sb.toString();
258 public void validate() throws TException {
259 // check for required fields