tech.deepdreams.security.serializers.UserCreatedEventSerializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of identity-events Show documentation
Show all versions of identity-events Show documentation
Mangement security project for Spring Boot
The newest version!
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.UserCreatedEvent;
public class UserCreatedEventSerializer extends JsonSerializer{
@Override
public void serialize(UserCreatedEvent 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.writeBooleanField("admin", event.isAdmin());
jsonGenerator.writeNumberField("subscriberId", event.getSubscriberId());
jsonGenerator.writeEndObject();
}
}