/** * Autogenerated by Thrift Compiler (0.9.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated */ package org.elasticsearch.thrift; import org.apache.thrift.scheme.IScheme; import org.apache.thrift.scheme.SchemeFactory; import org.apache.thrift.scheme.StandardScheme; import org.apache.thrift.scheme.TupleScheme; import org.apache.thrift.protocol.TTupleProtocol; import org.apache.thrift.protocol.TProtocolException; import org.apache.thrift.EncodingUtils; import org.apache.thrift.TException; import java.util.List; import java.util.ArrayList; import java.util.Map; import java.util.HashMap; import java.util.EnumMap; import java.util.Set; import java.util.HashSet; import java.util.EnumSet; import java.util.Collections; import java.util.BitSet; import java.nio.ByteBuffer; import java.util.Arrays; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class RestResponse implements org.apache.thrift.TBase<RestResponse, RestResponse._Fields>, java.io.Serializable, Cloneable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("RestResponse"); private static final org.apache.thrift.protocol.TField STATUS_FIELD_DESC = new org.apache.thrift.protocol.TField("status", org.apache.thrift.protocol.TType.I32, (short)1); private static final org.apache.thrift.protocol.TField HEADERS_FIELD_DESC = new org.apache.thrift.protocol.TField("headers", org.apache.thrift.protocol.TType.MAP, (short)2); private static final org.apache.thrift.protocol.TField BODY_FIELD_DESC = new org.apache.thrift.protocol.TField("body", org.apache.thrift.protocol.TType.STRING, (short)3); private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); static { schemes.put(StandardScheme.class, new RestResponseStandardSchemeFactory()); schemes.put(TupleScheme.class, new RestResponseTupleSchemeFactory()); } /** * * @see Status */ public Status status; // required public Map<String,String> headers; // optional public ByteBuffer body; // optional /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { /** * * @see Status */ STATUS((short)1, "status"), HEADERS((short)2, "headers"), BODY((short)3, "body"); private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); static { for (_Fields field : EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 1: // STATUS return STATUS; case 2: // HEADERS return HEADERS; case 3: // BODY return BODY; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(String name) { return byName.get(name); } private final short _thriftId; private final String _fieldName; _Fields(short thriftId, String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public String getFieldName() { return _fieldName; } } // isset id assignments private _Fields optionals[] = {_Fields.HEADERS,_Fields.BODY}; public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.STATUS, new org.apache.thrift.meta_data.FieldMetaData("status", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, Status.class))); tmpMap.put(_Fields.HEADERS, new org.apache.thrift.meta_data.FieldMetaData("headers", org.apache.thrift.TFieldRequirementType.OPTIONAL, new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING), new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)))); tmpMap.put(_Fields.BODY, new org.apache.thrift.meta_data.FieldMetaData("body", org.apache.thrift.TFieldRequirementType.OPTIONAL, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true))); metaDataMap = Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(RestResponse.class, metaDataMap); } public RestResponse() { } public RestResponse( Status status) { this(); this.status = status; } /** * Performs a deep copy on <i>other</i>. */ public RestResponse(RestResponse other) { if (other.isSetStatus()) { this.status = other.status; } if (other.isSetHeaders()) { Map<String,String> __this__headers = new HashMap<String,String>(); for (Map.Entry<String, String> other_element : other.headers.entrySet()) { String other_element_key = other_element.getKey(); String other_element_value = other_element.getValue(); String __this__headers_copy_key = other_element_key; String __this__headers_copy_value = other_element_value; __this__headers.put(__this__headers_copy_key, __this__headers_copy_value); } this.headers = __this__headers; } if (other.isSetBody()) { this.body = org.apache.thrift.TBaseHelper.copyBinary(other.body); ; } } public RestResponse deepCopy() { return new RestResponse(this); } @Override public void clear() { this.status = null; this.headers = null; this.body = null; } /** * * @see Status */ public Status getStatus() { return this.status; } /** * * @see Status */ public RestResponse setStatus(Status status) { this.status = status; return this; } public void unsetStatus() { this.status = null; } /** Returns true if field status is set (has been assigned a value) and false otherwise */ public boolean isSetStatus() { return this.status != null; } public void setStatusIsSet(boolean value) { if (!value) { this.status = null; } } public int getHeadersSize() { return (this.headers == null) ? 0 : this.headers.size(); } public void putToHeaders(String key, String val) { if (this.headers == null) { this.headers = new HashMap<String,String>(); } this.headers.put(key, val); } public Map<String,String> getHeaders() { return this.headers; } public RestResponse setHeaders(Map<String,String> headers) { this.headers = headers; return this; } public void unsetHeaders() { this.headers = null; } /** Returns true if field headers is set (has been assigned a value) and false otherwise */ public boolean isSetHeaders() { return this.headers != null; } public void setHeadersIsSet(boolean value) { if (!value) { this.headers = null; } } public byte[] getBody() { setBody(org.apache.thrift.TBaseHelper.rightSize(body)); return body == null ? null : body.array(); } public ByteBuffer bufferForBody() { return body; } public RestResponse setBody(byte[] body) { setBody(body == null ? (ByteBuffer)null : ByteBuffer.wrap(body)); return this; } public RestResponse setBody(ByteBuffer body) { this.body = body; return this; } public void unsetBody() { this.body = null; } /** Returns true if field body is set (has been assigned a value) and false otherwise */ public boolean isSetBody() { return this.body != null; } public void setBodyIsSet(boolean value) { if (!value) { this.body = null; } } public void setFieldValue(_Fields field, Object value) { switch (field) { case STATUS: if (value == null) { unsetStatus(); } else { setStatus((Status)value); } break; case HEADERS: if (value == null) { unsetHeaders(); } else { setHeaders((Map<String,String>)value); } break; case BODY: if (value == null) { unsetBody(); } else { setBody((ByteBuffer)value); } break; } } public Object getFieldValue(_Fields field) { switch (field) { case STATUS: return getStatus(); case HEADERS: return getHeaders(); case BODY: return getBody(); } throw new IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new IllegalArgumentException(); } switch (field) { case STATUS: return isSetStatus(); case HEADERS: return isSetHeaders(); case BODY: return isSetBody(); } throw new IllegalStateException(); } @Override public boolean equals(Object that) { if (that == null) return false; if (that instanceof RestResponse) return this.equals((RestResponse)that); return false; } public boolean equals(RestResponse that) { if (that == null) return false; boolean this_present_status = true && this.isSetStatus(); boolean that_present_status = true && that.isSetStatus(); if (this_present_status || that_present_status) { if (!(this_present_status && that_present_status)) return false; if (!this.status.equals(that.status)) return false; } boolean this_present_headers = true && this.isSetHeaders(); boolean that_present_headers = true && that.isSetHeaders(); if (this_present_headers || that_present_headers) { if (!(this_present_headers && that_present_headers)) return false; if (!this.headers.equals(that.headers)) return false; } boolean this_present_body = true && this.isSetBody(); boolean that_present_body = true && that.isSetBody(); if (this_present_body || that_present_body) { if (!(this_present_body && that_present_body)) return false; if (!this.body.equals(that.body)) return false; } return true; } @Override public int hashCode() { return 0; } public int compareTo(RestResponse other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; RestResponse typedOther = (RestResponse)other; lastComparison = Boolean.valueOf(isSetStatus()).compareTo(typedOther.isSetStatus()); if (lastComparison != 0) { return lastComparison; } if (isSetStatus()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.status, typedOther.status); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetHeaders()).compareTo(typedOther.isSetHeaders()); if (lastComparison != 0) { return lastComparison; } if (isSetHeaders()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.headers, typedOther.headers); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetBody()).compareTo(typedOther.isSetBody()); if (lastComparison != 0) { return lastComparison; } if (isSetBody()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.body, typedOther.body); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { schemes.get(iprot.getScheme()).getScheme().read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { schemes.get(oprot.getScheme()).getScheme().write(oprot, this); } @Override public String toString() { StringBuilder sb = new StringBuilder("RestResponse("); boolean first = true; sb.append("status:"); if (this.status == null) { sb.append("null"); } else { sb.append(this.status); } first = false; if (isSetHeaders()) { if (!first) sb.append(", "); sb.append("headers:"); if (this.headers == null) { sb.append("null"); } else { sb.append(this.headers); } first = false; } if (isSetBody()) { if (!first) sb.append(", "); sb.append("body:"); if (this.body == null) { sb.append("null"); } else { org.apache.thrift.TBaseHelper.toString(this.body, sb); } first = false; } sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields if (status == null) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'status' was not present! Struct: " + toString()); } // check for sub-struct validity } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { try { read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class RestResponseStandardSchemeFactory implements SchemeFactory { public RestResponseStandardScheme getScheme() { return new RestResponseStandardScheme(); } } private static class RestResponseStandardScheme extends StandardScheme<RestResponse> { public void read(org.apache.thrift.protocol.TProtocol iprot, RestResponse struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 1: // STATUS if (schemeField.type == org.apache.thrift.protocol.TType.I32) { struct.status = Status.findByValue(iprot.readI32()); struct.setStatusIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 2: // HEADERS if (schemeField.type == org.apache.thrift.protocol.TType.MAP) { { org.apache.thrift.protocol.TMap _map20 = iprot.readMapBegin(); struct.headers = new HashMap<String,String>(2*_map20.size); for (int _i21 = 0; _i21 < _map20.size; ++_i21) { String _key22; // required String _val23; // optional _key22 = iprot.readString(); _val23 = iprot.readString(); struct.headers.put(_key22, _val23); } iprot.readMapEnd(); } struct.setHeadersIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 3: // BODY if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.body = iprot.readBinary(); struct.setBodyIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, RestResponse struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.status != null) { oprot.writeFieldBegin(STATUS_FIELD_DESC); oprot.writeI32(struct.status.getValue()); oprot.writeFieldEnd(); } if (struct.headers != null) { if (struct.isSetHeaders()) { oprot.writeFieldBegin(HEADERS_FIELD_DESC); { oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, struct.headers.size())); for (Map.Entry<String, String> _iter24 : struct.headers.entrySet()) { oprot.writeString(_iter24.getKey()); oprot.writeString(_iter24.getValue()); } oprot.writeMapEnd(); } oprot.writeFieldEnd(); } } if (struct.body != null) { if (struct.isSetBody()) { oprot.writeFieldBegin(BODY_FIELD_DESC); oprot.writeBinary(struct.body); oprot.writeFieldEnd(); } } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class RestResponseTupleSchemeFactory implements SchemeFactory { public RestResponseTupleScheme getScheme() { return new RestResponseTupleScheme(); } } private static class RestResponseTupleScheme extends TupleScheme<RestResponse> { @Override public void write(org.apache.thrift.protocol.TProtocol prot, RestResponse struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; oprot.writeI32(struct.status.getValue()); BitSet optionals = new BitSet(); if (struct.isSetHeaders()) { optionals.set(0); } if (struct.isSetBody()) { optionals.set(1); } oprot.writeBitSet(optionals, 2); if (struct.isSetHeaders()) { { oprot.writeI32(struct.headers.size()); for (Map.Entry<String, String> _iter25 : struct.headers.entrySet()) { oprot.writeString(_iter25.getKey()); oprot.writeString(_iter25.getValue()); } } } if (struct.isSetBody()) { oprot.writeBinary(struct.body); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, RestResponse struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; struct.status = Status.findByValue(iprot.readI32()); struct.setStatusIsSet(true); BitSet incoming = iprot.readBitSet(2); if (incoming.get(0)) { { org.apache.thrift.protocol.TMap _map26 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32()); struct.headers = new HashMap<String,String>(2*_map26.size); for (int _i27 = 0; _i27 < _map26.size; ++_i27) { String _key28; // required String _val29; // optional _key28 = iprot.readString(); _val29 = iprot.readString(); struct.headers.put(_key28, _val29); } } struct.setHeadersIsSet(true); } if (incoming.get(1)) { struct.body = iprot.readBinary(); struct.setBodyIsSet(true); } } } }