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