Advertisement
Guest User

Untitled

a guest
Aug 24th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1. import java.util.HashMap;
  2. import java.util.Map;
  3.  
  4.  
  5. public class RestApiRequest {
  6.  
  7.   String path;
  8.   String method;
  9.   HashMap<String, String> params;
  10.  
  11.   public RestApiRequest(String path, String method, HashMap<String, String> params){
  12.     this.path = path;
  13.     this.method = method;
  14.     this.params = params;
  15.   }
  16.  
  17.   public String getParams(){
  18.     String result = "";
  19.     int n = params.entrySet().size();
  20.     int i = 1;
  21.     for ( Map.Entry<String, String> entry : params.entrySet()) {
  22.  
  23.       result+=entry.getKey() + "=" + entry.getValue();
  24.       if (i<n)
  25.         result += "&";
  26.       i++;
  27.     }
  28.     return result;
  29.   }
  30.  
  31.   public String getPath() {
  32.     return path;
  33.   }
  34.  
  35.   public String getMethod() {
  36.     return method;
  37.   }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement