forked from gooddata/gooddata-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGoodDataEndpoint.java
More file actions
88 lines (75 loc) · 2.58 KB
/
GoodDataEndpoint.java
File metadata and controls
88 lines (75 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
* Copyright (C) 2004-2017, GoodData(R) Corporation. All rights reserved.
* This source code is licensed under the BSD-style license found in the
* LICENSE.txt file in the root directory of this source tree.
*/
package com.gooddata;
import org.apache.http.HttpHost;
import static com.gooddata.util.Validate.notEmpty;
/**
* GoodData Platform endpoint represented by host, port and protocol
*/
public class GoodDataEndpoint {
public static final String PROTOCOL = "https";
public static final int PORT = 443;
public static final String HOSTNAME = "secure.gooddata.com";
private final String hostname;
private final int port;
private final String protocol;
/**
* Create GoodData endpoint for given hostname, port and protocol
* @param hostname GoodData Platform's host name (e.g. secure.gooddata.com)
* @param port GoodData Platform's API port (e.g. 443)
* @param protocol GoodData Platform's API protocol (e.g. https)
*/
public GoodDataEndpoint(final String hostname, final int port, final String protocol) {
this.hostname = notEmpty(hostname, "hostname");
this.port = port;
this.protocol = notEmpty(protocol, "protocol");
}
/**
* Create GoodData endpoint for given hostname, port using HTTPS protocol
* @param hostname GoodData Platform's host name (e.g. secure.gooddata.com)
* @param port GoodData Platform's API port (e.g. 443)
*/
public GoodDataEndpoint(String hostname, int port) {
this(hostname, port, PROTOCOL);
}
/**
* Create GoodData endpoint for given hostname using 443 port and HTTPS protocol
* @param hostname GoodData Platform's host name (e.g. secure.gooddata.com)
*/
public GoodDataEndpoint(String hostname) {
this(hostname, PORT, PROTOCOL);
}
/**
* Create GoodData endpoint for given hostname using 443 port and HTTPS protocol and secure.gooddata.com hostname
*/
public GoodDataEndpoint() {
this(HOSTNAME, PORT, PROTOCOL);
}
/**
* @return the host URI, as a string.
*/
public String toUri() {
return new HttpHost(hostname, port, protocol).toURI();
}
/**
* @return GoodData Platform's host name (e.g. secure.gooddata.com)
*/
public String getHostname() {
return hostname;
}
/**
* @return GoodData Platform's API port (e.g. 443)
*/
public int getPort() {
return port;
}
/**
* @return GoodData Platform's API protocol (e.g. https)
*/
public String getProtocol() {
return protocol;
}
}