com.foresee.api.sdk.common.Environment Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of public-api-sdk Show documentation
Show all versions of public-api-sdk Show documentation
SDK to access Foresee data over Public API
package com.foresee.api.sdk.common;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Iterables;
import com.google.common.collect.Multimap;
import lombok.Getter;
import java.util.NoSuchElementException;
@Getter
public enum Environment {
DEVELOPMENT("dev","https://api-dev.foresee.com"),
QA("qa","https://api-qa.foresee.com"),
STAGING("stg","https://api-stage.foresee.com"),
PRODUCTION("prod","https://api.foresee.com");
/** Static Map to store */
private static Multimap map = HashMultimap.create();
/** String representation Value indicating the type of environment */
private final String value;
/** Corresponding API URL */
private final String gatewayBaseUrl;
/**
* Private constructor to initialize the enum
* @param val The string representation for this enum
*/
private Environment(final String val, final String gatewayUrl) {
this.value = val;
this.gatewayBaseUrl = gatewayUrl;
}
/**
* Construct the map of Environments
*/
static {
for (Environment environment : Environment.values()) {
map.put(environment.value, environment);
}
}
public static Environment fromString(String val) {
if (map.containsKey(val)) {
return Iterables.get(map.get(val), 0);
}
throw new NoSuchElementException(val + " not found");
}
public String toString() {
return value;
}
}