1 package org.eclipse.aether.repository;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 public final class Proxy
26 {
27
28
29
30
31 public static final String TYPE_HTTP = "http";
32
33
34
35
36 public static final String TYPE_HTTPS = "https";
37
38 private final String type;
39
40 private final String host;
41
42 private final int port;
43
44 private final Authentication auth;
45
46
47
48
49
50
51
52
53 public Proxy( String type, String host, int port )
54 {
55 this( type, host, port, null );
56 }
57
58
59
60
61
62
63
64
65
66 public Proxy( String type, String host, int port, Authentication auth )
67 {
68 this.type = ( type != null ) ? type : "";
69 this.host = ( host != null ) ? host : "";
70 this.port = port;
71 this.auth = auth;
72 }
73
74
75
76
77
78
79 public String getType()
80 {
81 return type;
82 }
83
84
85
86
87
88
89 public String getHost()
90 {
91 return host;
92 }
93
94
95
96
97
98
99 public int getPort()
100 {
101 return port;
102 }
103
104
105
106
107
108
109 public Authentication getAuthentication()
110 {
111 return auth;
112 }
113
114 @Override
115 public String toString()
116 {
117 return getHost() + ':' + getPort();
118 }
119
120 @Override
121 public boolean equals( Object obj )
122 {
123 if ( this == obj )
124 {
125 return true;
126 }
127 if ( obj == null || !getClass().equals( obj.getClass() ) )
128 {
129 return false;
130 }
131
132 Proxy that = (Proxy) obj;
133
134 return eq( type, that.type ) && eq( host, that.host ) && port == that.port && eq( auth, that.auth );
135 }
136
137 private static <T> boolean eq( T s1, T s2 )
138 {
139 return s1 != null ? s1.equals( s2 ) : s2 == null;
140 }
141
142 @Override
143 public int hashCode()
144 {
145 int hash = 17;
146 hash = hash * 31 + hash( host );
147 hash = hash * 31 + hash( type );
148 hash = hash * 31 + port;
149 hash = hash * 31 + hash( auth );
150 return hash;
151 }
152
153 private static int hash( Object obj )
154 {
155 return obj != null ? obj.hashCode() : 0;
156 }
157
158 }