daily pastebin goal
31%
SHARE
TWEET

bloodyRequests

ghallas Dec 13th, 2018 (edited) 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class ErrorType1 {
  2.   private int errCode;
  3.  
  4.   public ErrorType1(int errCode) {
  5.     this.errCode = errCode;
  6.   }
  7.  
  8.   public int getErrCode() {
  9.     return errCode;
  10.   }
  11. }
  12.  
  13. class Response1  {
  14.    private ErrorType1 errorType1;
  15.    private int intField;
  16.  
  17.   public Response1(ErrorType1 errorType1, int intField) {
  18.     this.errorType1 = errorType1;
  19.     this.intField = intField;
  20.   }
  21.  
  22.   public ErrorType1 getErrorType() {
  23.     return errorType1;
  24.   }
  25.  
  26.   public int getIntField() {
  27.     return intField;
  28.   }
  29. }
  30.  
  31. class ErrorType2 {
  32.   private int errCode;
  33.  
  34.   public ErrorType2(int errCode) {
  35.     this.errCode = errCode;
  36.   }
  37.  
  38.   public int getErrCode() {
  39.     return errCode;
  40.   }
  41. }
  42.  
  43. class Response2  {
  44.   private ErrorType2 errorType2;
  45.   private String stringField;
  46.  
  47.   public Response2(ErrorType2 errorType1, String stringField) {
  48.     this.errorType2 = errorType1;
  49.     this.stringField = stringField;
  50.   }
  51.  
  52.   public ErrorType2 getErrorType() {
  53.     return errorType2;
  54.   }
  55.  
  56.   public String getStringField() {
  57.     return stringField;
  58.   }
  59. }
  60.  
  61. class RequestErrorExtractor {
  62.   public int getErrorCode(Response1 response) {
  63.     if (response != null && response.getErrorType() != null) {
  64.       return response.getErrorType().getErrCode();
  65.     }
  66.     return -1;
  67.   }
  68.  
  69.   public int getErrorCode(Response2 response) {
  70.     if (response != null && response.getErrorType() != null) {
  71.       return response.getErrorType().getErrCode();
  72.     }
  73.     return -1;
  74.   }
  75. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top