class FederationServer {

    public FederationResponse resolveAddress(String address) {
        String[] tokens = address.split("\\*");
        if (tokens.length != 2) {
            throw new MalformedAddressException();
        }

        URL uri = HttpUrl.parse(serverUri.toString()).newBuilder()
                .addQueryParameter("type", "name")
                .addQueryParameter("q", address)
                .build().url();

        TypeToken type = new TypeToken<FederationResponse>() {
        };
        ResponseHandler<FederationResponse> responseHandler = new ResponseHandler<FederationResponse>(httpClient, type);

        Request request = new Request.Builder()
                .url(uri.toString())
                .get()
                .build();

        try {
            Response response = httpClient.newCall(request)
                    .execute();
            return responseHandler.handleResponse(response);
        } catch (HttpResponseException e) {
            if (e.getStatusCode() == 404) {
                throw new NotFoundException();
            } else {
                throw new ServerErrorException();
            }
        } catch (IOException e) {
            throw new ConnectionErrorException();
        }
    }

    public  FederationServer(URL serverUri, String domain);
    public  FederationServer(String serverUri, String domain);

}