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

com.amazon.speech.speechlet.interfaces.system.SystemState Maven / Gradle / Ivy

There is a newer version: 1.8.1
Show newest version
/*
    Copyright 2014-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.

    Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file
    except in compliance with the License. A copy of the License is located at

        http://aws.amazon.com/apache2.0/

    or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for
    the specific language governing permissions and limitations under the License.
 */

package com.amazon.speech.speechlet.interfaces.system;

import com.amazon.speech.speechlet.Application;
import com.amazon.speech.speechlet.Device;
import com.amazon.speech.speechlet.State;
import com.amazon.speech.speechlet.User;
import com.fasterxml.jackson.annotation.JsonProperty;

public final class SystemState extends State {
    private final Application application;
    private final User user;
    private final Device device;
    private final String apiEndpoint;
    private final String apiAccessToken;

    /**
     * Returns a new builder instance used to construct a new {@code SystemState}.
     *
     * @return the builder
     */
    public static Builder builder() {
        return new Builder();
    }

    /**
     * Private constructor to return a new {@code SystemState} from a {@code Builder}.
     *
     * @param builder
     *            the builder used to construct the {@code SystemState}.
     */
    private SystemState(final Builder builder) {
        application = builder.application;
        user = builder.user;
        device = builder.device;
        apiEndpoint = builder.apiEndpoint;
        apiAccessToken = builder.apiAccessToken;
    }

    /**
     * Private constructor used for JSON serialization and for extending this class.
     *
     * @param application
     *            the application object
     * @param user
     *            the user object
     * @param device
     *            the device object
     * @param apiEndpoint
     *            the endpoint to be used to access Alexa API resources for the user
     * @param apiAccessToken
     *            the token to authenticate with Alexa API resources
     */
    private SystemState(@JsonProperty("application") final Application application,
            @JsonProperty("user") final User user,
            @JsonProperty("device") final Device device,
            @JsonProperty("apiEndpoint") final String apiEndpoint,
            @JsonProperty("apiAccessToken") final String apiAccessToken) {
        this.application = application;
        this.user = user;
        this.device = device;
        this.apiEndpoint = apiEndpoint;
        this.apiAccessToken = apiAccessToken;
    }

    /**
     * Returns the {@link Application} associated with this state.
     *
     * @return {@link Application} object
     */
    public Application getApplication() {
        return application;
    }

    /**
     * Returns the {@link User} associated with this state.
     *
     * @return {@link User} object
     */
    public User getUser() {
        return user;
    }

    /**
     * Returns the {@link Device} associated with this state.
     *
     * @return {@link Device} object
     */
    public Device getDevice() {
        return device;
    }

    /**
     * Returns the API endpoint value.
     *
     * @return API endpoint value
     */
    public String getApiEndpoint() {
        return apiEndpoint;
    }

    /**
     * Returns the API access token.
     *
     * @return the API access token
     */
    public String getApiAccessToken() {
        return apiAccessToken;
    }

    @Override
    public Class getInterfaceClass() {
        return SystemInterface.class;
    }

    /**
     * Builder used to construct a new {@code SystemState}.
     */
    public static final class Builder {
        private Application application;
        private User user;
        private Device device;
        private String apiEndpoint;
        private String apiAccessToken;

        private Builder() {
        }

        public Builder withApplication(final Application application) {
            this.application = application;
            return this;
        }

        public Builder withUser(final User user) {
            this.user = user;
            return this;
        }

        public Builder withDevice(final Device device) {
            this.device = device;
            return this;
        }

        public Builder withApiEndpoint(final String apiEndpoint) {
            this.apiEndpoint = apiEndpoint;
            return this;
        }

        public Builder withApiAccessToken(final String apiAccessToken) {
            this.apiAccessToken = apiAccessToken;
            return this;
        }

        public SystemState build() {
            return new SystemState(this);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy