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

com.github.edgar615.util.event.MessageCodec 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
 */
public class MessageCodec implements EventActionCodec {
  @Override
  public EventAction decode(Map map) {
    String resource = (String) map.get("resource");
    Map content = (Map) map.get("content");
    return Message.create(resource, content);
  }

  @Override
  public Map encode(EventAction action) {
    Message message = (Message) action;
    Map map = new HashMap<>();
    map.put("resource", message.resource());
    map.put("content", message.content());
    return map;
  }

  @Override
  public String name() {
    return Message.TYPE;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy