]>
git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.repo/src/org/eclipse/aether/repository/Proxy.java
1 /*******************************************************************************
2 * Copyright (c) 2010, 2012 Sonatype, Inc.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * Sonatype, Inc. - initial API and implementation
10 *******************************************************************************/
11 package org
.eclipse
.aether
.repository
;
14 * A proxy to use for connections to a repository.
16 public final class Proxy
20 * Type denoting a proxy for HTTP transfers.
22 public static final String TYPE_HTTP
= "http";
25 * Type denoting a proxy for HTTPS transfers.
27 public static final String TYPE_HTTPS
= "https";
29 private final String type
;
31 private final String host
;
33 private final int port
;
35 private final Authentication auth
;
38 * Creates a new proxy with the specified properties and no authentication.
40 * @param type The type of the proxy, e.g. "http", may be {@code null}.
41 * @param host The host of the proxy, may be {@code null}.
42 * @param port The port of the proxy.
44 public Proxy( String type
, String host
, int port
)
46 this( type
, host
, port
, null );
50 * Creates a new proxy with the specified properties.
52 * @param type The type of the proxy, e.g. "http", may be {@code null}.
53 * @param host The host of the proxy, may be {@code null}.
54 * @param port The port of the proxy.
55 * @param auth The authentication to use for the proxy connection, may be {@code null}.
57 public Proxy( String type
, String host
, int port
, Authentication auth
)
59 this.type
= ( type
!= null ) ? type
: "";
60 this.host
= ( host
!= null ) ? host
: "";
66 * Gets the type of this proxy.
68 * @return The type of this proxy, never {@code null}.
70 public String
getType()
76 * Gets the host for this proxy.
78 * @return The host for this proxy, never {@code null}.
80 public String
getHost()
86 * Gets the port number for this proxy.
88 * @return The port number for this proxy.
96 * Gets the authentication to use for the proxy connection.
98 * @return The authentication to use or {@code null} if none.
100 public Authentication
getAuthentication()
106 public String
toString()
108 return getHost() + ':' + getPort();
112 public boolean equals( Object obj
)
118 if ( obj
== null || !getClass().equals( obj
.getClass() ) )
123 Proxy that
= (Proxy
) obj
;
125 return eq( type
, that
.type
) && eq( host
, that
.host
) && port
== that
.port
&& eq( auth
, that
.auth
);
128 private static <T
> boolean eq( T s1
, T s2
)
130 return s1
!= null ? s1
.equals( s2
) : s2
== null;
134 public int hashCode()
137 hash
= hash
* 31 + hash( host
);
138 hash
= hash
* 31 + hash( type
);
139 hash
= hash
* 31 + port
;
140 hash
= hash
* 31 + hash( auth
);
144 private static int hash( Object obj
)
146 return obj
!= null ? obj
.hashCode() : 0;