All Downloads are FREE. Search and download functionalities are using the official Maven repository.

tech.deepdreams.security.serializers.UserCreatedEventSerializer Maven / Gradle / Ivy

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();
    }

}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy