1 /** 2 * Autogenerated by Thrift 3 * 4 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 * @generated 6 */ 7 package test.fixtures.adapter; 8 9 import java.util.List; 10 import java.util.ArrayList; 11 import java.util.Map; 12 import java.util.HashMap; 13 import java.util.Set; 14 import java.util.HashSet; 15 import java.util.Collections; 16 import java.util.BitSet; 17 import java.util.Arrays; 18 import org.slf4j.Logger; 19 import org.slf4j.LoggerFactory; 20 21 import com.facebook.thrift.*; 22 import com.facebook.thrift.annotations.*; 23 import com.facebook.thrift.async.*; 24 import com.facebook.thrift.meta_data.*; 25 import com.facebook.thrift.server.*; 26 import com.facebook.thrift.transport.*; 27 import com.facebook.thrift.protocol.*; 28 29 @SuppressWarnings({ "unused", "serial" }) 30 public class Service { 31 32 public interface Iface { 33 func(String arg1, String arg2, Foo arg3)34 public Integer func(String arg1, String arg2, Foo arg3) throws TException; 35 36 } 37 38 public interface AsyncIface { 39 func(String arg1, String arg2, Foo arg3, AsyncMethodCallback resultHandler)40 public void func(String arg1, String arg2, Foo arg3, AsyncMethodCallback resultHandler) throws TException; 41 42 } 43 44 public static class Client extends EventHandlerBase implements Iface, TClientIf { Client(TProtocol prot)45 public Client(TProtocol prot) 46 { 47 this(prot, prot); 48 } 49 Client(TProtocol iprot, TProtocol oprot)50 public Client(TProtocol iprot, TProtocol oprot) 51 { 52 iprot_ = iprot; 53 oprot_ = oprot; 54 } 55 56 protected TProtocol iprot_; 57 protected TProtocol oprot_; 58 59 protected int seqid_; 60 61 @Override getInputProtocol()62 public TProtocol getInputProtocol() 63 { 64 return this.iprot_; 65 } 66 67 @Override getOutputProtocol()68 public TProtocol getOutputProtocol() 69 { 70 return this.oprot_; 71 } 72 func(String arg1, String arg2, Foo arg3)73 public Integer func(String arg1, String arg2, Foo arg3) throws TException 74 { 75 ContextStack ctx = getContextStack("Service.func", null); 76 this.setContextStack(ctx); 77 send_func(arg1, arg2, arg3); 78 return recv_func(); 79 } 80 send_func(String arg1, String arg2, Foo arg3)81 public void send_func(String arg1, String arg2, Foo arg3) throws TException 82 { 83 ContextStack ctx = this.getContextStack(); 84 super.preWrite(ctx, "Service.func", null); 85 oprot_.writeMessageBegin(new TMessage("func", TMessageType.CALL, seqid_)); 86 func_args args = new func_args(); 87 args.arg1 = arg1; 88 args.arg2 = arg2; 89 args.arg3 = arg3; 90 args.write(oprot_); 91 oprot_.writeMessageEnd(); 92 oprot_.getTransport().flush(); 93 super.postWrite(ctx, "Service.func", args); 94 return; 95 } 96 recv_func()97 public Integer recv_func() throws TException 98 { 99 ContextStack ctx = super.getContextStack(); 100 long bytes; 101 TMessageType mtype; 102 super.preRead(ctx, "Service.func"); 103 TMessage msg = iprot_.readMessageBegin(); 104 if (msg.type == TMessageType.EXCEPTION) { 105 TApplicationException x = TApplicationException.read(iprot_); 106 iprot_.readMessageEnd(); 107 throw x; 108 } 109 func_result result = func_result.deserialize(iprot_); 110 iprot_.readMessageEnd(); 111 super.postRead(ctx, "Service.func", result); 112 113 if (result.isSetSuccess()) { 114 return result.success; 115 } 116 throw new TApplicationException(TApplicationException.MISSING_RESULT, "func failed: unknown result"); 117 } 118 119 } 120 public static class AsyncClient extends TAsyncClient implements AsyncIface { 121 public static class Factory implements TAsyncClientFactory<AsyncClient> { 122 private TAsyncClientManager clientManager; 123 private TProtocolFactory protocolFactory; Factory(TAsyncClientManager clientManager, TProtocolFactory protocolFactory)124 public Factory(TAsyncClientManager clientManager, TProtocolFactory protocolFactory) { 125 this.clientManager = clientManager; 126 this.protocolFactory = protocolFactory; 127 } getAsyncClient(TNonblockingTransport transport)128 public AsyncClient getAsyncClient(TNonblockingTransport transport) { 129 return new AsyncClient(protocolFactory, clientManager, transport); 130 } 131 } 132 AsyncClient(TProtocolFactory protocolFactory, TAsyncClientManager clientManager, TNonblockingTransport transport)133 public AsyncClient(TProtocolFactory protocolFactory, TAsyncClientManager clientManager, TNonblockingTransport transport) { 134 super(protocolFactory, clientManager, transport); 135 } 136 func(String arg1, String arg2, Foo arg3, AsyncMethodCallback resultHandler51)137 public void func(String arg1, String arg2, Foo arg3, AsyncMethodCallback resultHandler51) throws TException { 138 checkReady(); 139 func_call method_call = new func_call(arg1, arg2, arg3, resultHandler51, this, ___protocolFactory, ___transport); 140 this.___currentMethod = method_call; 141 ___manager.call(method_call); 142 } 143 144 public static class func_call extends TAsyncMethodCall { 145 private String arg1; 146 private String arg2; 147 private Foo arg3; func_call(String arg1, String arg2, Foo arg3, AsyncMethodCallback resultHandler52, TAsyncClient client48, TProtocolFactory protocolFactory49, TNonblockingTransport transport50)148 public func_call(String arg1, String arg2, Foo arg3, AsyncMethodCallback resultHandler52, TAsyncClient client48, TProtocolFactory protocolFactory49, TNonblockingTransport transport50) throws TException { 149 super(client48, protocolFactory49, transport50, resultHandler52, false); 150 this.arg1 = arg1; 151 this.arg2 = arg2; 152 this.arg3 = arg3; 153 } 154 write_args(TProtocol prot)155 public void write_args(TProtocol prot) throws TException { 156 prot.writeMessageBegin(new TMessage("func", TMessageType.CALL, 0)); 157 func_args args = new func_args(); 158 args.setArg1(arg1); 159 args.setArg2(arg2); 160 args.setArg3(arg3); 161 args.write(prot); 162 prot.writeMessageEnd(); 163 } 164 getResult()165 public Integer getResult() throws TException { 166 if (getState() != State.RESPONSE_READ) { 167 throw new IllegalStateException("Method call not finished!"); 168 } 169 TMemoryInputTransport memoryTransport = new TMemoryInputTransport(getFrameBuffer().array()); 170 TProtocol prot = super.client.getProtocolFactory().getProtocol(memoryTransport); 171 return (new Client(prot)).recv_func(); 172 } 173 } 174 175 } 176 177 public static class Processor implements TProcessor { 178 private static final Logger LOGGER = LoggerFactory.getLogger(Processor.class.getName()); Processor(Iface iface)179 public Processor(Iface iface) 180 { 181 iface_ = iface; 182 event_handler_ = new TProcessorEventHandler(); // Empty handler 183 processMap_.put("func", new func()); 184 } 185 186 protected static interface ProcessFunction { process(int seqid, TProtocol iprot, TProtocol oprot, TConnectionContext server_ctx)187 public void process(int seqid, TProtocol iprot, TProtocol oprot, TConnectionContext server_ctx) throws TException; 188 } 189 setEventHandler(TProcessorEventHandler handler)190 public void setEventHandler(TProcessorEventHandler handler) { 191 this.event_handler_ = handler; 192 } 193 194 private Iface iface_; 195 protected TProcessorEventHandler event_handler_; 196 protected final HashMap<String,ProcessFunction> processMap_ = new HashMap<String,ProcessFunction>(); 197 process(TProtocol iprot, TProtocol oprot, TConnectionContext server_ctx)198 public boolean process(TProtocol iprot, TProtocol oprot, TConnectionContext server_ctx) throws TException 199 { 200 TMessage msg = iprot.readMessageBegin(); 201 ProcessFunction fn = processMap_.get(msg.name); 202 if (fn == null) { 203 TProtocolUtil.skip(iprot, TType.STRUCT); 204 iprot.readMessageEnd(); 205 TApplicationException x = new TApplicationException(TApplicationException.UNKNOWN_METHOD, "Invalid method name: '"+msg.name+"'"); 206 oprot.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid)); 207 x.write(oprot); 208 oprot.writeMessageEnd(); 209 oprot.getTransport().flush(); 210 return true; 211 } 212 fn.process(msg.seqid, iprot, oprot, server_ctx); 213 return true; 214 } 215 216 private class func implements ProcessFunction { process(int seqid, TProtocol iprot, TProtocol oprot, TConnectionContext server_ctx)217 public void process(int seqid, TProtocol iprot, TProtocol oprot, TConnectionContext server_ctx) throws TException 218 { 219 Object handler_ctx = event_handler_.getContext("Service.func", server_ctx); 220 func_args args = new func_args(); 221 event_handler_.preRead(handler_ctx, "Service.func"); 222 args.read(iprot); 223 iprot.readMessageEnd(); 224 event_handler_.postRead(handler_ctx, "Service.func", args); 225 func_result result = new func_result(); 226 result.success = iface_.func(args.arg1, args.arg2, args.arg3); 227 event_handler_.preWrite(handler_ctx, "Service.func", result); 228 oprot.writeMessageBegin(new TMessage("func", TMessageType.REPLY, seqid)); 229 result.write(oprot); 230 oprot.writeMessageEnd(); 231 oprot.getTransport().flush(); 232 event_handler_.postWrite(handler_ctx, "Service.func", result); 233 } 234 235 } 236 237 } 238 239 public static class func_args implements TBase, java.io.Serializable, Cloneable { 240 private static final TStruct STRUCT_DESC = new TStruct("func_args"); 241 private static final TField ARG1_FIELD_DESC = new TField("arg1", TType.STRING, (short)1); 242 private static final TField ARG2_FIELD_DESC = new TField("arg2", TType.STRING, (short)2); 243 private static final TField ARG3_FIELD_DESC = new TField("arg3", TType.STRUCT, (short)3); 244 245 public String arg1; 246 public String arg2; 247 public Foo arg3; 248 public static final int ARG1 = 1; 249 public static final int ARG2 = 2; 250 public static final int ARG3 = 3; 251 252 // isset id assignments 253 254 func_args()255 public func_args() { 256 } 257 func_args( String arg1, String arg2, Foo arg3)258 public func_args( 259 String arg1, 260 String arg2, 261 Foo arg3) { 262 this.arg1 = arg1; 263 this.arg2 = arg2; 264 this.arg3 = arg3; 265 } 266 267 /** 268 * Performs a deep copy on <i>other</i>. 269 */ func_args(func_args other)270 public func_args(func_args other) { 271 if (other.isSetArg1()) { 272 this.arg1 = TBaseHelper.deepCopy(other.arg1); 273 } 274 if (other.isSetArg2()) { 275 this.arg2 = TBaseHelper.deepCopy(other.arg2); 276 } 277 if (other.isSetArg3()) { 278 this.arg3 = TBaseHelper.deepCopy(other.arg3); 279 } 280 } 281 deepCopy()282 public func_args deepCopy() { 283 return new func_args(this); 284 } 285 getArg1()286 public String getArg1() { 287 return this.arg1; 288 } 289 setArg1(String arg1)290 public func_args setArg1(String arg1) { 291 this.arg1 = arg1; 292 return this; 293 } 294 unsetArg1()295 public void unsetArg1() { 296 this.arg1 = null; 297 } 298 299 // Returns true if field arg1 is set (has been assigned a value) and false otherwise isSetArg1()300 public boolean isSetArg1() { 301 return this.arg1 != null; 302 } 303 setArg1IsSet(boolean __value)304 public void setArg1IsSet(boolean __value) { 305 if (!__value) { 306 this.arg1 = null; 307 } 308 } 309 getArg2()310 public String getArg2() { 311 return this.arg2; 312 } 313 setArg2(String arg2)314 public func_args setArg2(String arg2) { 315 this.arg2 = arg2; 316 return this; 317 } 318 unsetArg2()319 public void unsetArg2() { 320 this.arg2 = null; 321 } 322 323 // Returns true if field arg2 is set (has been assigned a value) and false otherwise isSetArg2()324 public boolean isSetArg2() { 325 return this.arg2 != null; 326 } 327 setArg2IsSet(boolean __value)328 public void setArg2IsSet(boolean __value) { 329 if (!__value) { 330 this.arg2 = null; 331 } 332 } 333 getArg3()334 public Foo getArg3() { 335 return this.arg3; 336 } 337 setArg3(Foo arg3)338 public func_args setArg3(Foo arg3) { 339 this.arg3 = arg3; 340 return this; 341 } 342 unsetArg3()343 public void unsetArg3() { 344 this.arg3 = null; 345 } 346 347 // Returns true if field arg3 is set (has been assigned a value) and false otherwise isSetArg3()348 public boolean isSetArg3() { 349 return this.arg3 != null; 350 } 351 setArg3IsSet(boolean __value)352 public void setArg3IsSet(boolean __value) { 353 if (!__value) { 354 this.arg3 = null; 355 } 356 } 357 358 @Override equals(Object _that)359 public boolean equals(Object _that) { 360 if (_that == null) 361 return false; 362 if (this == _that) 363 return true; 364 if (!(_that instanceof func_args)) 365 return false; 366 func_args that = (func_args)_that; 367 368 if (!TBaseHelper.equalsNobinary(this.isSetArg1(), that.isSetArg1(), this.arg1, that.arg1)) { return false; } 369 370 if (!TBaseHelper.equalsNobinary(this.isSetArg2(), that.isSetArg2(), this.arg2, that.arg2)) { return false; } 371 372 if (!TBaseHelper.equalsNobinary(this.isSetArg3(), that.isSetArg3(), this.arg3, that.arg3)) { return false; } 373 374 return true; 375 } 376 377 @Override hashCode()378 public int hashCode() { 379 return Arrays.deepHashCode(new Object[] {arg1, arg2, arg3}); 380 } 381 382 // This is required to satisfy the TBase interface, but can't be implemented on immutable struture. read(TProtocol iprot)383 public void read(TProtocol iprot) throws TException { 384 throw new TException("unimplemented in android immutable structure"); 385 } 386 deserialize(TProtocol iprot)387 public static func_args deserialize(TProtocol iprot) throws TException { 388 String tmp_arg1 = null; 389 String tmp_arg2 = null; 390 Foo tmp_arg3 = null; 391 TField __field; 392 iprot.readStructBegin(); 393 while (true) 394 { 395 __field = iprot.readFieldBegin(); 396 if (__field.type == TType.STOP) { 397 break; 398 } 399 switch (__field.id) 400 { 401 case ARG1: 402 if (__field.type == TType.STRING) { 403 tmp_arg1 = iprot.readString(); 404 } else { 405 TProtocolUtil.skip(iprot, __field.type); 406 } 407 break; 408 case ARG2: 409 if (__field.type == TType.STRING) { 410 tmp_arg2 = iprot.readString(); 411 } else { 412 TProtocolUtil.skip(iprot, __field.type); 413 } 414 break; 415 case ARG3: 416 if (__field.type == TType.STRUCT) { 417 tmp_arg3 = Foo.deserialize(iprot); 418 } else { 419 TProtocolUtil.skip(iprot, __field.type); 420 } 421 break; 422 default: 423 TProtocolUtil.skip(iprot, __field.type); 424 break; 425 } 426 iprot.readFieldEnd(); 427 } 428 iprot.readStructEnd(); 429 430 func_args _that; 431 _that = new func_args( 432 tmp_arg1 433 ,tmp_arg2 434 ,tmp_arg3 435 ); 436 _that.validate(); 437 return _that; 438 } 439 write(TProtocol oprot)440 public void write(TProtocol oprot) throws TException { 441 validate(); 442 443 oprot.writeStructBegin(STRUCT_DESC); 444 if (this.arg1 != null) { 445 oprot.writeFieldBegin(ARG1_FIELD_DESC); 446 oprot.writeString(this.arg1); 447 oprot.writeFieldEnd(); 448 } 449 if (this.arg2 != null) { 450 oprot.writeFieldBegin(ARG2_FIELD_DESC); 451 oprot.writeString(this.arg2); 452 oprot.writeFieldEnd(); 453 } 454 if (this.arg3 != null) { 455 oprot.writeFieldBegin(ARG3_FIELD_DESC); 456 this.arg3.write(oprot); 457 oprot.writeFieldEnd(); 458 } 459 oprot.writeFieldStop(); 460 oprot.writeStructEnd(); 461 } 462 463 @Override toString()464 public String toString() { 465 return toString(1, true); 466 } 467 468 @Override toString(int indent, boolean prettyPrint)469 public String toString(int indent, boolean prettyPrint) { 470 return TBaseHelper.toStringHelper(this, indent, prettyPrint); 471 } 472 validate()473 public void validate() throws TException { 474 // check for required fields 475 } 476 477 } 478 479 public static class func_result implements TBase, java.io.Serializable, Cloneable { 480 private static final TStruct STRUCT_DESC = new TStruct("func_result"); 481 private static final TField SUCCESS_FIELD_DESC = new TField("success", TType.I32, (short)0); 482 483 public Integer success; 484 public static final int SUCCESS = 0; 485 486 // isset id assignments 487 488 func_result()489 public func_result() { 490 } 491 func_result( Integer success)492 public func_result( 493 Integer success) { 494 this.success = success; 495 } 496 497 /** 498 * Performs a deep copy on <i>other</i>. 499 */ func_result(func_result other)500 public func_result(func_result other) { 501 if (other.isSetSuccess()) { 502 this.success = TBaseHelper.deepCopy(other.success); 503 } 504 } 505 deepCopy()506 public func_result deepCopy() { 507 return new func_result(this); 508 } 509 getSuccess()510 public Integer getSuccess() { 511 return this.success; 512 } 513 setSuccess(Integer success)514 public func_result setSuccess(Integer success) { 515 this.success = success; 516 return this; 517 } 518 unsetSuccess()519 public void unsetSuccess() { 520 this.success = null; 521 } 522 523 // Returns true if field success is set (has been assigned a value) and false otherwise isSetSuccess()524 public boolean isSetSuccess() { 525 return this.success != null; 526 } 527 setSuccessIsSet(boolean __value)528 public void setSuccessIsSet(boolean __value) { 529 if (!__value) { 530 this.success = null; 531 } 532 } 533 534 @Override equals(Object _that)535 public boolean equals(Object _that) { 536 if (_that == null) 537 return false; 538 if (this == _that) 539 return true; 540 if (!(_that instanceof func_result)) 541 return false; 542 func_result that = (func_result)_that; 543 544 if (!TBaseHelper.equalsNobinary(this.isSetSuccess(), that.isSetSuccess(), this.success, that.success)) { return false; } 545 546 return true; 547 } 548 549 @Override hashCode()550 public int hashCode() { 551 return Arrays.deepHashCode(new Object[] {success}); 552 } 553 554 // This is required to satisfy the TBase interface, but can't be implemented on immutable struture. read(TProtocol iprot)555 public void read(TProtocol iprot) throws TException { 556 throw new TException("unimplemented in android immutable structure"); 557 } 558 deserialize(TProtocol iprot)559 public static func_result deserialize(TProtocol iprot) throws TException { 560 Integer tmp_success = null; 561 TField __field; 562 iprot.readStructBegin(); 563 while (true) 564 { 565 __field = iprot.readFieldBegin(); 566 if (__field.type == TType.STOP) { 567 break; 568 } 569 switch (__field.id) 570 { 571 case SUCCESS: 572 if (__field.type == TType.I32) { 573 tmp_success = iprot.readI32(); 574 } else { 575 TProtocolUtil.skip(iprot, __field.type); 576 } 577 break; 578 default: 579 TProtocolUtil.skip(iprot, __field.type); 580 break; 581 } 582 iprot.readFieldEnd(); 583 } 584 iprot.readStructEnd(); 585 586 func_result _that; 587 _that = new func_result( 588 tmp_success 589 ); 590 _that.validate(); 591 return _that; 592 } 593 write(TProtocol oprot)594 public void write(TProtocol oprot) throws TException { 595 oprot.writeStructBegin(STRUCT_DESC); 596 597 if (this.isSetSuccess()) { 598 oprot.writeFieldBegin(SUCCESS_FIELD_DESC); 599 oprot.writeI32(this.success); 600 oprot.writeFieldEnd(); 601 } 602 oprot.writeFieldStop(); 603 oprot.writeStructEnd(); 604 } 605 606 @Override toString()607 public String toString() { 608 return toString(1, true); 609 } 610 611 @Override toString(int indent, boolean prettyPrint)612 public String toString(int indent, boolean prettyPrint) { 613 return TBaseHelper.toStringHelper(this, indent, prettyPrint); 614 } 615 validate()616 public void validate() throws TException { 617 // check for required fields 618 } 619 620 } 621 622 } 623