forked from TrueCloudLab/frostfs-sdk-java
parent
c9a54d56fb
commit
23bbe08893
70 changed files with 1375 additions and 587 deletions
|
@ -1,14 +1,20 @@
|
|||
package info.frostfs.sdk.jdo;
|
||||
|
||||
import io.grpc.Channel;
|
||||
import io.grpc.ChannelCredentials;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
public class ClientSettings {
|
||||
private static final String ERROR_TEMPLATE = "%s is required parameter.";
|
||||
import static java.util.Objects.isNull;
|
||||
|
||||
public String key;
|
||||
public String host;
|
||||
public ChannelCredentials creds;
|
||||
public class ClientSettings {
|
||||
private static final String ERROR_TEMPLATE = "%s required parameter.";
|
||||
private static final String KEY_NAME = "Key";
|
||||
private static final String HOST_AND_CHANNEL_NAME = "Host or Channel";
|
||||
|
||||
private final String key;
|
||||
private String host;
|
||||
private ChannelCredentials credentials;
|
||||
private Channel channel;
|
||||
|
||||
public ClientSettings(String key, String host) {
|
||||
this.key = key;
|
||||
|
@ -16,46 +22,44 @@ public class ClientSettings {
|
|||
validate();
|
||||
}
|
||||
|
||||
public ClientSettings(String key, String host, ChannelCredentials creds) {
|
||||
public ClientSettings(String key, String host, ChannelCredentials credentials) {
|
||||
this.key = key;
|
||||
this.host = host;
|
||||
this.creds = creds;
|
||||
this.credentials = credentials;
|
||||
validate();
|
||||
}
|
||||
|
||||
public ChannelCredentials getCreds() {
|
||||
return creds;
|
||||
public ClientSettings(String key, Channel channel) {
|
||||
this.key = key;
|
||||
this.channel = channel;
|
||||
validate();
|
||||
}
|
||||
|
||||
public void setCreds(ChannelCredentials creds) {
|
||||
this.creds = creds;
|
||||
public Channel getChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
public ChannelCredentials getCredentials() {
|
||||
return credentials;
|
||||
}
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public void validate() {
|
||||
StringBuilder errorMessage = new StringBuilder();
|
||||
|
||||
if (StringUtils.isEmpty(key)) {
|
||||
errorMessage.append(String.format(ERROR_TEMPLATE, "Key")).append(System.lineSeparator());
|
||||
errorMessage.append(String.format(ERROR_TEMPLATE, KEY_NAME)).append(System.lineSeparator());
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(host)) {
|
||||
errorMessage.append(String.format(ERROR_TEMPLATE, "Host")).append(System.lineSeparator());
|
||||
if (StringUtils.isEmpty(host) && isNull(channel)) {
|
||||
errorMessage.append(String.format(ERROR_TEMPLATE, HOST_AND_CHANNEL_NAME)).append(System.lineSeparator());
|
||||
}
|
||||
|
||||
if (errorMessage.length() != 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue