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

io.klerch.alexa.state.model.serializer.AlexaSessionStateSerializer Maven / Gradle / Ivy

Go to download

This SDK is an extension to the Alexa Skills SDK for Java. It provides a framework for managing state of POJO models in a variety of persistence stores in an Alexa skill.

There is a newer version: 1.1.0
Show newest version
/**
 * Made by Kay Lerch (https://twitter.com/KayLerch)
 *
 * Attached license applies.
 * This library is licensed under GNU GENERAL PUBLIC LICENSE Version 3 as of 29 June 2007
 */
package io.klerch.alexa.state.model.serializer;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import io.klerch.alexa.state.model.AlexaScope;
import io.klerch.alexa.state.model.AlexaStateModel;

import java.io.IOException;

/**
 * The serializer considers all fields in a model tagged with AlexaStateSave and scoped with SESSION or a scope
 * which includes SESSION.
 */
public class AlexaSessionStateSerializer extends AlexaStateSerializer {
    @Override
    public void serialize(AlexaStateModel alexaStateModel, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
        serializerProvider.setAttribute(this.scopeAttributeKey, AlexaScope.SESSION);
        super.serialize(alexaStateModel, jsonGenerator, serializerProvider);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy