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

com.smartcar.sdk.SmartcarAuthOptions Maven / Gradle / Ivy

There is a newer version: 4.6.0
Show newest version
package com.smartcar.sdk;

import java.util.ArrayList;
import java.util.List;

/**
 * Class encompassing any optional arguments for Smartcar Authorization requests
 */
public final class SmartcarAuthOptions {
    private String flags;

    public static class Builder {
        private final List flags;

        public Builder() {
            this.flags = new ArrayList<>();
        }

        public Builder addFlag(String key, String value) {
            this.flags.add(key + ":" + value);
            return this;
        }

        public Builder addFlag(String key, boolean value) {
            this.flags.add(key + ":" + value);
            return this;
        }

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

    private SmartcarAuthOptions(Builder builder) {
        if (builder.flags.size() > 0) {
            String[] flagStrings = builder.flags.toArray(new String[0]);
            this.flags = Utils.join(flagStrings, " ");
        } else {
            this.flags = null;
        }
    }

    public String getFlags() {
        return this.flags;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy