tech.deepdreams.employee.serializers.EmployeeAccessRevokedEventSerializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of employee-events Show documentation
Show all versions of employee-events Show documentation
HR employee events project for Spring Boot
The newest version!
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.EmployeeAccessRevokedEvent;
public class EmployeeAccessRevokedEventSerializer extends JsonSerializer{
@Override
public void serialize(EmployeeAccessRevokedEvent 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("accessCode", event.getAccessCode());
jsonGenerator.writeStringField("username", event.getUsername());
jsonGenerator.writeEndObject();
}
}