io.klerch.alexa.state.model.serializer.AlexaAppStateSerializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of alexa-skills-kit-states-java Show documentation
Show all versions of alexa-skills-kit-states-java Show documentation
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.
/**
* 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 APPLICATION or a scope
* which includes APPLICATION.
*/
public class AlexaAppStateSerializer extends AlexaStateSerializer {
@Override
public void serialize(AlexaStateModel alexaStateModel, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
serializerProvider.setAttribute(this.scopeAttributeKey, AlexaScope.APPLICATION);
super.serialize(alexaStateModel, jsonGenerator, serializerProvider);
}
}