com.github.edgar615.util.event.RequestCodec Maven / Gradle / Ivy
package com.github.edgar615.util.event;
import java.util.HashMap;
import java.util.Map;
/**
* Created by Edgar on 2017/3/22.
*
* @author Edgar Date 2017/3/22
*/
@Deprecated
public class RequestCodec implements EventActionCodec {
@Override
public EventAction decode(Map map) {
String op = (String) map.get("operation");
String resource = (String) map.get("resource");
Map content = (Map) map.get("content");
return Request.create(resource,op, content);
}
@Override
public Map encode(EventAction action) {
Request request = (Request) action;
Map map = new HashMap<>();
map.put("resource", request.resource());
map.put("operation", request.operation());
map.put("content", request.content());
return map;
}
@Override
public String name() {
return Request.TYPE;
}
}