1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package io.netty.handler.proxy;
18
19 import io.netty.util.internal.ObjectUtil;
20 import io.netty.util.internal.StringUtil;
21
22 import java.net.SocketAddress;
23
24 public final class ProxyConnectionEvent {
25
26 private final String protocol;
27 private final String authScheme;
28 private final SocketAddress proxyAddress;
29 private final SocketAddress destinationAddress;
30 private String strVal;
31
32
33
34
35 public ProxyConnectionEvent(
36 String protocol, String authScheme, SocketAddress proxyAddress, SocketAddress destinationAddress) {
37 this.protocol = ObjectUtil.checkNotNull(protocol, "protocol");
38 this.authScheme = ObjectUtil.checkNotNull(authScheme, "authScheme");
39 this.proxyAddress = ObjectUtil.checkNotNull(proxyAddress, "proxyAddress");
40 this.destinationAddress = ObjectUtil.checkNotNull(destinationAddress, "destinationAddress");
41 }
42
43
44
45
46 public String protocol() {
47 return protocol;
48 }
49
50
51
52
53 public String authScheme() {
54 return authScheme;
55 }
56
57
58
59
60 @SuppressWarnings("unchecked")
61 public <T extends SocketAddress> T proxyAddress() {
62 return (T) proxyAddress;
63 }
64
65
66
67
68 @SuppressWarnings("unchecked")
69 public <T extends SocketAddress> T destinationAddress() {
70 return (T) destinationAddress;
71 }
72
73 @Override
74 public String toString() {
75 if (strVal != null) {
76 return strVal;
77 }
78
79 StringBuilder buf = new StringBuilder(128)
80 .append(StringUtil.simpleClassName(this))
81 .append('(')
82 .append(protocol)
83 .append(", ")
84 .append(authScheme)
85 .append(", ")
86 .append(proxyAddress)
87 .append(" => ")
88 .append(destinationAddress)
89 .append(')');
90
91 return strVal = buf.toString();
92 }
93 }