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

com.lowdad.thrift.client.utils.ThriftUrlStr Maven / Gradle / Ivy

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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy