Android Open Source - android-NestDK Client Metadata

From Project

Back to project page android-NestDK.


The source code is released under:

Apache License

If you think the Android project android-NestDK listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

 * Copyright 2014 Nest Labs Inc. 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.
 * You may obtain a copy of the License at
 * Unless required by applicable law or agreed to in writing, software * distributed under
 * the License 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./*from   w ww .  jav a  2s  .  c o  m*/

package com.nestapi.lib;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.Random;

public final class ClientMetadata implements Parcelable {
    private final String mClientID;
    private final String mStateValue;
    private final String mClientSecret;
    private final String mRedirectURL;

    private ClientMetadata(Builder builder) {
        mClientID = builder.mClientID;
        mStateValue = builder.mStateValue;
        mClientSecret = builder.mClientSecret;
        mRedirectURL = builder.mRedirectURL;

    private ClientMetadata(Parcel in) {
        mClientID = in.readString();
        mStateValue = in.readString();
        mClientSecret = in.readString();
        mRedirectURL = in.readString();

    public String getClientID() {
        return mClientID;

    public String getStateValue() {
        return mStateValue;

    public String getClientSecret() {
        return mClientSecret;

    public String getRedirectURL() {
        return mRedirectURL;

    public static class Builder {
        private String mClientID;
        private String mRedirectURL;
        private String mStateValue;
        private String mClientSecret;

        public Builder setClientID(String clientID) {
            mClientID = clientID;
            return this;

        public Builder setClientSecret(String clientSecret) {
            mClientSecret = clientSecret;
            return this;

        public Builder setRedirectURL(String redirectURL) {
            mRedirectURL = redirectURL;
            return this;

        private Builder setStateValue(String state) {
            mStateValue = state;
            return this;

        public ClientMetadata build() {
            //Create random state value on each creation
            setStateValue("app-state" + System.nanoTime() + "-" + new Random().nextInt());
            return new ClientMetadata(this);

    public int describeContents() {
        return 0;

    public void writeToParcel(Parcel dest, int flags) {

    public static final Parcelable.Creator<ClientMetadata> CREATOR = new Parcelable.Creator<ClientMetadata>() {
        public ClientMetadata createFromParcel(Parcel source) {
            return new ClientMetadata(source);

        public ClientMetadata[] newArray(int size) {
            return new ClientMetadata[size];

Java Source Code List