package com.megatim.fdxconsultation.service.impl.sockets.encoders; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.megatim.fdxconsultation.model.supervision.Transfert; import java.io.IOException; import javax.websocket.DecodeException; import javax.websocket.Decoder; import javax.websocket.EndpointConfig; /** * * @author lenovo */ public class TranfertDecoder implements Decoder.Text { private final ObjectMapper objectMapper = new ObjectMapper(); @Override public Transfert decode(String s) throws DecodeException { try { return objectMapper.readValue(s, new TypeReference() { }); } catch (IOException 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() { } }