BAEL-1994: Moved the code to libraries module

This commit is contained in:
DomWos
2018-08-18 20:20:29 +02:00
parent e828a0de9a
commit 610d0ce869
12 changed files with 17 additions and 38 deletions

View File

@@ -0,0 +1,33 @@
package com.baeldung.schema;
import com.baeldung.model.InputMessage;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import org.apache.flink.api.common.serialization.DeserializationSchema;
import org.apache.flink.api.common.typeinfo.TypeInformation;
import java.io.IOException;
public class InputMessageDeserializationSchema implements
DeserializationSchema<InputMessage> {
ObjectMapper objectMapper;
@Override
public InputMessage deserialize(byte[] bytes) throws IOException {
if(objectMapper == null) {
objectMapper = new ObjectMapper().registerModule(new JavaTimeModule());
}
return objectMapper.readValue(bytes, InputMessage.class);
}
@Override
public boolean isEndOfStream(InputMessage inputMessage) {
return false;
}
@Override
public TypeInformation<InputMessage> getProducedType() {
return TypeInformation.of(InputMessage.class);
}
}