tech.deepdreams.employee.serializers.ContractStartedEventSerializer Maven / Gradle / Ivy
package tech.deepdreams.employee.serializers;
import java.io.IOException;
import java.time.format.DateTimeFormatter;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import tech.deepdreams.employee.events.ContractStartedEvent;
public class ContractStartedEventSerializer extends JsonSerializer{
@Override
public void serialize(ContractStartedEvent event, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
jsonGenerator.writeStartObject();
jsonGenerator.writeNumberField("id", event.getId());
jsonGenerator.writeNumberField("employeeId", event.getEmployeeId());
jsonGenerator.writeStringField("eventDate", event.getEventDate().format(DateTimeFormatter.ISO_OFFSET_DATE_TIME));
jsonGenerator.writeStringField("hiringDate", event.getHiringDate().format(DateTimeFormatter.ISO_DATE));
jsonGenerator.writeStringField("contractType", event.getContractType().name());
jsonGenerator.writeNumberField("contractDuration", event.getContractDuration());
jsonGenerator.writeNumberField("baseSalary", event.getBaseSalary()) ;
jsonGenerator.writeNumberField("weeklyWorkingHours", event.getWeeklyWorkingHours()) ;
jsonGenerator.writeNumberField("annualLeaveDays", event.getAnnualLeaveDays()) ;
jsonGenerator.writeNumberField("retirementAge", event.getRetirementAge()) ;
jsonGenerator.writeNumberField("unitId", event.getUnitId()) ;
jsonGenerator.writeNumberField("functionId", event.getFunctionId()) ;
jsonGenerator.writeNumberField("categoryId", event.getCategoryId()) ;
jsonGenerator.writeNumberField("echelonId", event.getEchelonId()) ;
jsonGenerator.writeStringField("username", event.getUsername());
jsonGenerator.writeEndObject();
}
}