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

tech.deepdreams.security.deserializers.UserRecoveredEventDeserializer Maven / Gradle / Ivy

package tech.deepdreams.security.deserializers;
import java.io.IOException;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonNode;
import tech.deepdreams.security.events.UserDisabledEvent;

public class UserRecoveredEventDeserializer extends JsonDeserializer{
	
	
	@Override
    public UserDisabledEvent deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
        JsonNode jsonNode = jsonParser.getCodec().readTree(jsonParser);
        Long id = jsonNode.get("id").asLong();
        String nickname = jsonNode.get("nickname").asText() ;
        String email = jsonNode.get("email").asText() ;
        OffsetDateTime eventDate = OffsetDateTime.parse(jsonNode.get("eventDate").asText(), DateTimeFormatter.ISO_DATE_TIME) ;
        String description = jsonNode.get("description").asText() ;
        Long subscriberId = jsonNode.get("subscriberId").asLong();

        return UserDisabledEvent.builder()
        		    	.id(id) 
        		    	.nickname(nickname)
        		    	.email(email)
        		    	.eventDate(eventDate)
        		    	.description(description)
        		    	.subscriberId(subscriberId)
        		    	.build() ;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy