dev.sixpack.generator.SupplierConfig Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sixpack-sdk Show documentation
Show all versions of sixpack-sdk Show documentation
SDK to develop generators part of the Sixpack solution
The newest version!
package dev.sixpack.generator;
import lombok.Data;
import static dev.sixpack.utils.FormatUtils.mFormat;
import static java.lang.System.getenv;
@Data
public class SupplierConfig {
public static final String SIXPACK_URL = "SIXPACK_URL";
public static final String SIXPACK_ACCOUNT = "SIXPACK_ACCOUNT";
public static final String SIXPACK_CLIENT_CERT_PATH = "SIXPACK_CLIENT_CERT_PATH";
public static final String SIXPACK_CLIENT_KEY_PATH = "SIXPACK_CLIENT_KEY_PATH";
public static final String SIXPACK_ENVIRONMENT = "SIXPACK_ENVIRONMENT";
private String sixpackUrl;
private String account;
private String clientCertificatePath;
private String clientKeyPath;
private String environment;
private Generator[] generators;
private Class extends Orchestrator>[] orchestrators;
public SupplierConfig(String sixpackUrl,
String account,
String clientCertificatePath,
String clientKeyPath,
String environment) {
this.sixpackUrl = sixpackUrl;
this.account = account;
this.clientCertificatePath = clientCertificatePath;
this.clientKeyPath = clientKeyPath;
this.environment = environment;
}
public static SupplierConfig fromEnv() {
return new SupplierConfig(
getenv(SIXPACK_URL),
getenv(SIXPACK_ACCOUNT),
getenv(SIXPACK_CLIENT_CERT_PATH),
getenv(SIXPACK_CLIENT_KEY_PATH),
getenv(SIXPACK_ENVIRONMENT));
}
public void verify() {
verifyNonNull(sixpackUrl, SIXPACK_URL);
verifyNonNull(account, SIXPACK_ACCOUNT);
verifyNonNull(clientCertificatePath, SIXPACK_CLIENT_CERT_PATH);
verifyNonNull(clientKeyPath, SIXPACK_CLIENT_KEY_PATH);
verifyNonNull(environment, SIXPACK_ENVIRONMENT);
}
private static final String emptyParameterError = "The environment variable {} must be set or the respective setter on your supplier needs to be called before bootstrapping the supplier";
private void verifyNonNull(String property, String envName) {
if (property == null) {
throw new IllegalArgumentException(mFormat(emptyParameterError, envName));
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy