Java tutorial
/** * Copyright 2016 benjobs * <p> * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * <p> * http://www.apache.org/licenses/LICENSE-2.0 * <p> * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package com.jredrain.base.job; import org.apache.thrift.EncodingUtils; import org.apache.thrift.protocol.TTupleProtocol; 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 java.util.*; import javax.annotation.Generated; @SuppressWarnings({ "cast", "rawtypes", "serial", "unchecked" }) @Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2016-05-30") public class Response implements org.apache.thrift.TBase<Response, Response._Fields>, java.io.Serializable, Cloneable, Comparable<Response> { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct( "Response"); private static final org.apache.thrift.protocol.TField ACTION_FIELD_DESC = new org.apache.thrift.protocol.TField( "action", org.apache.thrift.protocol.TType.I32, (short) 1); private static final org.apache.thrift.protocol.TField RESULT_FIELD_DESC = new org.apache.thrift.protocol.TField( "result", org.apache.thrift.protocol.TType.MAP, (short) 2); private static final org.apache.thrift.protocol.TField EXIT_CODE_FIELD_DESC = new org.apache.thrift.protocol.TField( "exitCode", org.apache.thrift.protocol.TType.I32, (short) 3); private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField( "success", org.apache.thrift.protocol.TType.BOOL, (short) 4); private static final org.apache.thrift.protocol.TField START_TIME_FIELD_DESC = new org.apache.thrift.protocol.TField( "startTime", org.apache.thrift.protocol.TType.I64, (short) 5); private static final org.apache.thrift.protocol.TField END_TIME_FIELD_DESC = new org.apache.thrift.protocol.TField( "endTime", org.apache.thrift.protocol.TType.I64, (short) 6); private static final org.apache.thrift.protocol.TField MESSAGE_FIELD_DESC = new org.apache.thrift.protocol.TField( "message", org.apache.thrift.protocol.TType.STRING, (short) 7); private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); static { schemes.put(StandardScheme.class, new ResponseStandardSchemeFactory()); schemes.put(TupleScheme.class, new ResponseTupleSchemeFactory()); } /** * * @see Action */ public Action action; // required public Map<String, String> result; // required public int exitCode; // required public boolean success; // required public long startTime; // required public long endTime; // required public String message; // required /** 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 Action */ ACTION((short) 1, "action"), RESULT((short) 2, "result"), EXIT_CODE((short) 3, "exitCode"), SUCCESS( (short) 4, "success"), START_TIME((short) 5, "startTime"), END_TIME((short) 6, "endTime"), MESSAGE((short) 7, "message"); 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: // ACTION return ACTION; case 2: // RESULT return RESULT; case 3: // EXIT_CODE return EXIT_CODE; case 4: // SUCCESS return SUCCESS; case 5: // START_TIME return START_TIME; case 6: // END_TIME return END_TIME; case 7: // MESSAGE return MESSAGE; 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 static final int __EXITCODE_ISSET_ID = 0; private static final int __SUCCESS_ISSET_ID = 1; private static final int __STARTTIME_ISSET_ID = 2; private static final int __ENDTIME_ISSET_ID = 3; private byte __isset_bitfield = 0; 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.ACTION, new org.apache.thrift.meta_data.FieldMetaData("action", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, Action.class))); tmpMap.put(_Fields.RESULT, new org.apache.thrift.meta_data.FieldMetaData("result", org.apache.thrift.TFieldRequirementType.DEFAULT, 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.EXIT_CODE, new org.apache.thrift.meta_data.FieldMetaData("exitCode", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))); tmpMap.put(_Fields.START_TIME, new org.apache.thrift.meta_data.FieldMetaData("startTime", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); tmpMap.put(_Fields.END_TIME, new org.apache.thrift.meta_data.FieldMetaData("endTime", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); tmpMap.put(_Fields.MESSAGE, new org.apache.thrift.meta_data.FieldMetaData("message", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); metaDataMap = Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Response.class, metaDataMap); } public Response() { } public Response(Action action, Map<String, String> result, int exitCode, boolean success, long startTime, long endTime, String message) { this(); this.action = action; this.result = result; this.exitCode = exitCode; setExitCodeIsSet(true); this.success = success; setSuccessIsSet(true); this.startTime = startTime; setStartTimeIsSet(true); this.endTime = endTime; setEndTimeIsSet(true); this.message = message; } /** * Performs a deep copy on <i>other</i>. */ public Response(Response other) { __isset_bitfield = other.__isset_bitfield; if (other.isSetAction()) { this.action = other.action; } if (other.isSetResult()) { Map<String, String> __this__result = new HashMap<String, String>(other.result); this.result = __this__result; } this.exitCode = other.exitCode; this.success = other.success; this.startTime = other.startTime; this.endTime = other.endTime; if (other.isSetMessage()) { this.message = other.message; } } public Response deepCopy() { return new Response(this); } @Override public void clear() { this.action = null; this.result = null; setExitCodeIsSet(false); this.exitCode = 0; setSuccessIsSet(false); this.success = false; setStartTimeIsSet(false); this.startTime = 0; setEndTimeIsSet(false); this.endTime = 0; this.message = null; } /** * * @see Action */ public Action getAction() { return this.action; } /** * * @see Action */ public Response setAction(Action action) { this.action = action; return this; } public void unsetAction() { this.action = null; } /** Returns true if field action is set (has been assigned a value) and false otherwise */ public boolean isSetAction() { return this.action != null; } public void setActionIsSet(boolean value) { if (!value) { this.action = null; } } public int getResultSize() { return (this.result == null) ? 0 : this.result.size(); } public void putToResult(String key, String val) { if (this.result == null) { this.result = new HashMap<String, String>(); } this.result.put(key, val); } public Map<String, String> getResult() { return this.result; } public Response setResult(Map<String, String> result) { this.result = result; return this; } public void unsetResult() { this.result = null; } /** Returns true if field result is set (has been assigned a value) and false otherwise */ public boolean isSetResult() { return this.result != null; } public void setResultIsSet(boolean value) { if (!value) { this.result = null; } } public int getExitCode() { return this.exitCode; } public Response setExitCode(int exitCode) { this.exitCode = exitCode; setExitCodeIsSet(true); return this; } public void unsetExitCode() { __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __EXITCODE_ISSET_ID); } /** Returns true if field exitCode is set (has been assigned a value) and false otherwise */ public boolean isSetExitCode() { return EncodingUtils.testBit(__isset_bitfield, __EXITCODE_ISSET_ID); } public void setExitCodeIsSet(boolean value) { __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __EXITCODE_ISSET_ID, value); } public boolean isSuccess() { return this.success; } public Response setSuccess(boolean success) { this.success = success; setSuccessIsSet(true); return this; } public void unsetSuccess() { __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __SUCCESS_ISSET_ID); } /** Returns true if field success is set (has been assigned a value) and false otherwise */ public boolean isSetSuccess() { return EncodingUtils.testBit(__isset_bitfield, __SUCCESS_ISSET_ID); } public void setSuccessIsSet(boolean value) { __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __SUCCESS_ISSET_ID, value); } public long getStartTime() { return this.startTime; } public Response setStartTime(long startTime) { this.startTime = startTime; setStartTimeIsSet(true); return this; } public void unsetStartTime() { __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __STARTTIME_ISSET_ID); } /** Returns true if field startTime is set (has been assigned a value) and false otherwise */ public boolean isSetStartTime() { return EncodingUtils.testBit(__isset_bitfield, __STARTTIME_ISSET_ID); } public void setStartTimeIsSet(boolean value) { __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __STARTTIME_ISSET_ID, value); } public long getEndTime() { return this.endTime; } public Response setEndTime(long endTime) { this.endTime = endTime; setEndTimeIsSet(true); return this; } public void unsetEndTime() { __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __ENDTIME_ISSET_ID); } /** Returns true if field endTime is set (has been assigned a value) and false otherwise */ public boolean isSetEndTime() { return EncodingUtils.testBit(__isset_bitfield, __ENDTIME_ISSET_ID); } public void setEndTimeIsSet(boolean value) { __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __ENDTIME_ISSET_ID, value); } public String getMessage() { return this.message; } public Response setMessage(String message) { this.message = message; return this; } public void unsetMessage() { this.message = null; } /** Returns true if field message is set (has been assigned a value) and false otherwise */ public boolean isSetMessage() { return this.message != null; } public void setMessageIsSet(boolean value) { if (!value) { this.message = null; } } public void setFieldValue(_Fields field, Object value) { switch (field) { case ACTION: if (value == null) { unsetAction(); } else { setAction((Action) value); } break; case RESULT: if (value == null) { unsetResult(); } else { setResult((Map<String, String>) value); } break; case EXIT_CODE: if (value == null) { unsetExitCode(); } else { setExitCode((Integer) value); } break; case SUCCESS: if (value == null) { unsetSuccess(); } else { setSuccess((Boolean) value); } break; case START_TIME: if (value == null) { unsetStartTime(); } else { setStartTime((Long) value); } break; case END_TIME: if (value == null) { unsetEndTime(); } else { setEndTime((Long) value); } break; case MESSAGE: if (value == null) { unsetMessage(); } else { setMessage((String) value); } break; } } public Object getFieldValue(_Fields field) { switch (field) { case ACTION: return getAction(); case RESULT: return getResult(); case EXIT_CODE: return getExitCode(); case SUCCESS: return isSuccess(); case START_TIME: return getStartTime(); case END_TIME: return getEndTime(); case MESSAGE: return getMessage(); } 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 ACTION: return isSetAction(); case RESULT: return isSetResult(); case EXIT_CODE: return isSetExitCode(); case SUCCESS: return isSetSuccess(); case START_TIME: return isSetStartTime(); case END_TIME: return isSetEndTime(); case MESSAGE: return isSetMessage(); } throw new IllegalStateException(); } @Override public boolean equals(Object that) { if (that == null) return false; if (that instanceof Response) return this.equals((Response) that); return false; } public boolean equals(Response that) { if (that == null) return false; boolean this_present_action = true && this.isSetAction(); boolean that_present_action = true && that.isSetAction(); if (this_present_action || that_present_action) { if (!(this_present_action && that_present_action)) return false; if (!this.action.equals(that.action)) return false; } boolean this_present_result = true && this.isSetResult(); boolean that_present_result = true && that.isSetResult(); if (this_present_result || that_present_result) { if (!(this_present_result && that_present_result)) return false; if (!this.result.equals(that.result)) return false; } boolean this_present_exitCode = true; boolean that_present_exitCode = true; if (this_present_exitCode || that_present_exitCode) { if (!(this_present_exitCode && that_present_exitCode)) return false; if (this.exitCode != that.exitCode) return false; } boolean this_present_success = true; boolean that_present_success = true; if (this_present_success || that_present_success) { if (!(this_present_success && that_present_success)) return false; if (this.success != that.success) return false; } boolean this_present_startTime = true; boolean that_present_startTime = true; if (this_present_startTime || that_present_startTime) { if (!(this_present_startTime && that_present_startTime)) return false; if (this.startTime != that.startTime) return false; } boolean this_present_endTime = true; boolean that_present_endTime = true; if (this_present_endTime || that_present_endTime) { if (!(this_present_endTime && that_present_endTime)) return false; if (this.endTime != that.endTime) return false; } boolean this_present_message = true && this.isSetMessage(); boolean that_present_message = true && that.isSetMessage(); if (this_present_message || that_present_message) { if (!(this_present_message && that_present_message)) return false; if (!this.message.equals(that.message)) return false; } return true; } @Override public int hashCode() { List<Object> list = new ArrayList<Object>(); boolean present_action = true && (isSetAction()); list.add(present_action); if (present_action) list.add(action.getValue()); boolean present_result = true && (isSetResult()); list.add(present_result); if (present_result) list.add(result); boolean present_exitCode = true; list.add(present_exitCode); if (present_exitCode) list.add(exitCode); boolean present_success = true; list.add(present_success); if (present_success) list.add(success); boolean present_startTime = true; list.add(present_startTime); if (present_startTime) list.add(startTime); boolean present_endTime = true; list.add(present_endTime); if (present_endTime) list.add(endTime); boolean present_message = true && (isSetMessage()); list.add(present_message); if (present_message) list.add(message); return list.hashCode(); } @Override public int compareTo(Response other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = Boolean.valueOf(isSetAction()).compareTo(other.isSetAction()); if (lastComparison != 0) { return lastComparison; } if (isSetAction()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.action, other.action); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetResult()).compareTo(other.isSetResult()); if (lastComparison != 0) { return lastComparison; } if (isSetResult()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.result, other.result); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetExitCode()).compareTo(other.isSetExitCode()); if (lastComparison != 0) { return lastComparison; } if (isSetExitCode()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.exitCode, other.exitCode); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess()); if (lastComparison != 0) { return lastComparison; } if (isSetSuccess()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetStartTime()).compareTo(other.isSetStartTime()); if (lastComparison != 0) { return lastComparison; } if (isSetStartTime()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.startTime, other.startTime); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetEndTime()).compareTo(other.isSetEndTime()); if (lastComparison != 0) { return lastComparison; } if (isSetEndTime()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.endTime, other.endTime); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetMessage()).compareTo(other.isSetMessage()); if (lastComparison != 0) { return lastComparison; } if (isSetMessage()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.message, other.message); 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("Response("); boolean first = true; sb.append("action:"); if (this.action == null) { sb.append("null"); } else { sb.append(this.action); } first = false; if (!first) sb.append(", "); sb.append("result:"); if (this.result == null) { sb.append("null"); } else { sb.append(this.result); } first = false; if (!first) sb.append(", "); sb.append("exitCode:"); sb.append(this.exitCode); first = false; if (!first) sb.append(", "); sb.append("success:"); sb.append(this.success); first = false; if (!first) sb.append(", "); sb.append("startTime:"); sb.append(this.startTime); first = false; if (!first) sb.append(", "); sb.append("endTime:"); sb.append(this.endTime); first = false; if (!first) sb.append(", "); sb.append("message:"); if (this.message == null) { sb.append("null"); } else { sb.append(this.message); } first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // 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 { // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. __isset_bitfield = 0; 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 ResponseStandardSchemeFactory implements SchemeFactory { public ResponseStandardScheme getScheme() { return new ResponseStandardScheme(); } } private static class ResponseStandardScheme extends StandardScheme<Response> { public void read(org.apache.thrift.protocol.TProtocol iprot, Response 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: // ACTION if (schemeField.type == org.apache.thrift.protocol.TType.I32) { struct.action = com.jredrain.base.job.Action.findByValue(iprot.readI32()); struct.setActionIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 2: // RESULT if (schemeField.type == org.apache.thrift.protocol.TType.MAP) { { org.apache.thrift.protocol.TMap _map10 = iprot.readMapBegin(); struct.result = new HashMap<String, String>(2 * _map10.size); String _key11; String _val12; for (int _i13 = 0; _i13 < _map10.size; ++_i13) { _key11 = iprot.readString(); _val12 = iprot.readString(); struct.result.put(_key11, _val12); } iprot.readMapEnd(); } struct.setResultIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 3: // EXIT_CODE if (schemeField.type == org.apache.thrift.protocol.TType.I32) { struct.exitCode = iprot.readI32(); struct.setExitCodeIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 4: // SUCCESS if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) { struct.success = iprot.readBool(); struct.setSuccessIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 5: // START_TIME if (schemeField.type == org.apache.thrift.protocol.TType.I64) { struct.startTime = iprot.readI64(); struct.setStartTimeIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 6: // END_TIME if (schemeField.type == org.apache.thrift.protocol.TType.I64) { struct.endTime = iprot.readI64(); struct.setEndTimeIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 7: // MESSAGE if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.message = iprot.readString(); struct.setMessageIsSet(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, Response struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.action != null) { oprot.writeFieldBegin(ACTION_FIELD_DESC); oprot.writeI32(struct.action.getValue()); oprot.writeFieldEnd(); } if (struct.result != null) { oprot.writeFieldBegin(RESULT_FIELD_DESC); { oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, struct.result.size())); for (Map.Entry<String, String> _iter14 : struct.result.entrySet()) { oprot.writeString(_iter14.getKey()); oprot.writeString(_iter14.getValue()); } oprot.writeMapEnd(); } oprot.writeFieldEnd(); } oprot.writeFieldBegin(EXIT_CODE_FIELD_DESC); oprot.writeI32(struct.exitCode); oprot.writeFieldEnd(); oprot.writeFieldBegin(SUCCESS_FIELD_DESC); oprot.writeBool(struct.success); oprot.writeFieldEnd(); oprot.writeFieldBegin(START_TIME_FIELD_DESC); oprot.writeI64(struct.startTime); oprot.writeFieldEnd(); oprot.writeFieldBegin(END_TIME_FIELD_DESC); oprot.writeI64(struct.endTime); oprot.writeFieldEnd(); if (struct.message != null) { oprot.writeFieldBegin(MESSAGE_FIELD_DESC); oprot.writeString(struct.message); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class ResponseTupleSchemeFactory implements SchemeFactory { public ResponseTupleScheme getScheme() { return new ResponseTupleScheme(); } } private static class ResponseTupleScheme extends TupleScheme<Response> { @Override public void write(org.apache.thrift.protocol.TProtocol prot, Response struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; BitSet optionals = new BitSet(); if (struct.isSetAction()) { optionals.set(0); } if (struct.isSetResult()) { optionals.set(1); } if (struct.isSetExitCode()) { optionals.set(2); } if (struct.isSetSuccess()) { optionals.set(3); } if (struct.isSetStartTime()) { optionals.set(4); } if (struct.isSetEndTime()) { optionals.set(5); } if (struct.isSetMessage()) { optionals.set(6); } oprot.writeBitSet(optionals, 7); if (struct.isSetAction()) { oprot.writeI32(struct.action.getValue()); } if (struct.isSetResult()) { { oprot.writeI32(struct.result.size()); for (Map.Entry<String, String> _iter15 : struct.result.entrySet()) { oprot.writeString(_iter15.getKey()); oprot.writeString(_iter15.getValue()); } } } if (struct.isSetExitCode()) { oprot.writeI32(struct.exitCode); } if (struct.isSetSuccess()) { oprot.writeBool(struct.success); } if (struct.isSetStartTime()) { oprot.writeI64(struct.startTime); } if (struct.isSetEndTime()) { oprot.writeI64(struct.endTime); } if (struct.isSetMessage()) { oprot.writeString(struct.message); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, Response struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; BitSet incoming = iprot.readBitSet(7); if (incoming.get(0)) { struct.action = com.jredrain.base.job.Action.findByValue(iprot.readI32()); struct.setActionIsSet(true); } if (incoming.get(1)) { { org.apache.thrift.protocol.TMap _map16 = new org.apache.thrift.protocol.TMap( org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32()); struct.result = new HashMap<String, String>(2 * _map16.size); String _key17; String _val18; for (int _i19 = 0; _i19 < _map16.size; ++_i19) { _key17 = iprot.readString(); _val18 = iprot.readString(); struct.result.put(_key17, _val18); } } struct.setResultIsSet(true); } if (incoming.get(2)) { struct.exitCode = iprot.readI32(); struct.setExitCodeIsSet(true); } if (incoming.get(3)) { struct.success = iprot.readBool(); struct.setSuccessIsSet(true); } if (incoming.get(4)) { struct.startTime = iprot.readI64(); struct.setStartTimeIsSet(true); } if (incoming.get(5)) { struct.endTime = iprot.readI64(); struct.setEndTimeIsSet(true); } if (incoming.get(6)) { struct.message = iprot.readString(); struct.setMessageIsSet(true); } } } public Response start() { this.startTime = new Date().getTime(); return this; } public Response end() { this.endTime = new Date().getTime(); return this; } public static Response response(Request request) { return new Response().setAction(request.getAction()).start(); } }