SHARE
TWEET

Untitled

Cypgain Jan 10th, 2020 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.cypgain.api.commons.message;
  2.  
  3. import com.google.gson.Gson;
  4.  
  5. import java.util.HashMap;
  6. import java.util.Map;
  7.  
  8. public class RedisMessage
  9. {
  10.  
  11.     private MessageAction action;
  12.     private Map<String, String> params;
  13.  
  14.     public RedisMessage(MessageAction action)
  15.     {
  16.         this.action = action;
  17.         params = new HashMap<>();
  18.     }
  19.  
  20.     public RedisMessage setParam(String key, String value)
  21.     {
  22.         params.put(key, value);
  23.         return this;
  24.     }
  25.  
  26.     public String getParam(String key)
  27.     {
  28.         if (containsParam(key))
  29.         {
  30.             return params.get(key);
  31.         }
  32.         return null;
  33.     }
  34.  
  35.     public boolean containsParam(String key)
  36.     {
  37.         return params.containsKey(key);
  38.     }
  39.  
  40.     public void removeParam(String key)
  41.     {
  42.         if (containsParam(key))
  43.         {
  44.             params.remove(key);
  45.         }
  46.     }
  47.  
  48.     public String toJSON()
  49.     {
  50.         return new Gson().toJson(this);
  51.     }
  52.  
  53.     public MessageAction getAction()
  54.     {
  55.         return action;
  56.     }
  57. }
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