tech.deepdreams.security.serializers.UserActivatedEventSerializer Maven / Gradle / Ivy
package tech.deepdreams.security.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.security.events.UserActivatedEvent;
public class UserActivatedEventSerializer extends JsonSerializer{
@Override
public void serialize(UserActivatedEvent event, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
jsonGenerator.writeStartObject();
jsonGenerator.writeNumberField("id", event.getId());
jsonGenerator.writeStringField("nickname", event.getNickname()) ;
jsonGenerator.writeStringField("email", event.getEmail()) ;
jsonGenerator.writeStringField("eventDate", event.getEventDate().format(DateTimeFormatter.ISO_OFFSET_DATE_TIME));
jsonGenerator.writeStringField("description", event.getDescription());
jsonGenerator.writeNumberField("subscriberId", event.getSubscriberId());
jsonGenerator.writeEndObject();
}
}