All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.edgar615.util.event.RequestCodec Maven / Gradle / Ivy

There is a newer version: 1.0.11
Show newest version
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;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy