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 package org.apache.hc.core5.reactor;
28
29 import org.apache.hc.core5.annotation.Internal;
30 import org.apache.hc.core5.http.HttpHost;
31 import org.apache.hc.core5.net.NamedEndpoint;
32 import org.apache.hc.core5.net.Ports;
33 import org.apache.hc.core5.util.Args;
34
35
36
37
38
39
40 @Internal
41 public final class EndpointParameters implements NamedEndpoint {
42
43 private final String scheme;
44 private final String hostName;
45 private final int port;
46 private final Object attachment;
47
48 public EndpointParameters(final String scheme, final String hostName, final int port, final Object attachment) {
49 this.scheme = Args.notBlank(scheme, "Protocol scheme");
50 this.hostName = Args.notBlank(hostName, "Endpoint name");
51 this.port = Ports.checkWithDefault(port);
52 this.attachment = attachment;
53 }
54
55 public EndpointParameters(final HttpHost host, final Object attachment) {
56 Args.notNull(host, "HTTP host");
57 this.scheme = host.getSchemeName();
58 this.hostName = host.getHostName();
59 this.port = host.getPort();
60 this.attachment = attachment;
61 }
62
63 public String getScheme() {
64 return scheme;
65 }
66
67 @Override
68 public String getHostName() {
69 return hostName;
70 }
71
72 @Override
73 public int getPort() {
74 return port;
75 }
76
77 public Object getAttachment() {
78 return attachment;
79 }
80
81 @Override
82 public String toString() {
83 return "EndpointParameters{" +
84 "scheme='" + scheme + '\'' +
85 ", name='" + hostName + '\'' +
86 ", port=" + port +
87 ", attachment=" + attachment +
88 '}';
89 }
90
91 }