1 32 package net.sf.retrotranslator.runtime.java.net; 33 34 import java.net.SocketAddress ; 35 36 39 public class Proxy_ { 40 41 private final Type type; 42 private final SocketAddress address; 43 44 public enum Type { 45 DIRECT, HTTP, SOCKS 46 } 47 48 public static final Proxy_ NO_PROXY = new Proxy_(); 49 50 private Proxy_() { 51 this.type = Type.DIRECT; 52 this.address = null; 53 } 54 55 public Proxy_(Type type, SocketAddress address) { 56 this.type = type; 57 this.address = address; 58 } 59 60 public Type type() { 61 return type; 62 } 63 64 public SocketAddress address() { 65 return address; 66 } 67 68 public String toString() { 69 return type == Type.DIRECT ? Type.DIRECT.toString() : type() + " @ " + address(); 70 } 71 72 public final boolean equals(Object obj) { 73 if (obj instanceof Proxy_) { 74 Proxy_ proxy = (Proxy_) obj; 75 if (type() == proxy.type()) { 76 return address() == null ? proxy.address() == null : address().equals(proxy.address()); 77 } 78 } 79 return false; 80 } 81 82 public final int hashCode() { 83 return address() == null ? type().hashCode() : type().hashCode() + address().hashCode(); 84 } 85 } 86 | Popular Tags |