com.lowdad.thrift.client.utils.ThriftUrlStr Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rpc-client Show documentation
Show all versions of rpc-client Show documentation
RPC client for k8s services
The newest version!
package com.lowdad.thrift.client.utils;
import java.util.Optional;
/**
* @author lowdad
*/
public class ThriftUrlStr {
private String host;
private int port;
public ThriftUrlStr(String host, int port) {
this.setHost(host);
this.setPort(port);
}
public static Optional parse(String url) {
String tmp[] = url.split(":");
if (tmp.length != 2) {
return Optional.empty();
} else {
try {
return Optional.of(new ThriftUrlStr(tmp[0], Integer.parseInt(tmp[1])));
} catch (Exception e) {
return Optional.empty();
}
}
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public int getPort() {
return port;
}
public void setPort(int port) {
this.port = port;
}
}