package com.megatim.fdxconsultation.service.impl.sockets.encoders;
|
|
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
import java.util.List;
|
import java.util.Map;
|
import javax.websocket.DecodeException;
|
import javax.websocket.Decoder;
|
import javax.websocket.EndpointConfig;
|
|
/**
|
*
|
* @author lenovo
|
*/
|
public class ParticipantToFichiersDecoder implements Decoder.Text<Map<String, List<String>>> {
|
|
private ObjectMapper objectMapper = new ObjectMapper();
|
|
@Override
|
public Map<String, List<String>> decode(String s) throws DecodeException {
|
try {
|
return objectMapper.readValue(s, new TypeReference<Map<String, List<String>>>() {});
|
} catch (Exception e) {
|
throw new DecodeException(s, "Unable to decode map", e);
|
}
|
}
|
|
@Override
|
public boolean willDecode(String s) {
|
return s != null;
|
}
|
|
@Override
|
public void init(EndpointConfig endpointConfig) {
|
}
|
|
@Override
|
public void destroy() {
|
}
|
}
|