@SuppressWarnings("EqualsWhichDoesntCheckParameterClass") @Override public boolean equals(Object obj) { return url.equals(obj); }
@Override public boolean equals(@Nullable Object other) { return other instanceof Address && url.equals(((Address) other).url) && equalsNonHost((Address) other); }
@Override public boolean equals(@Nullable Object other) { return other instanceof Address && url.equals(((Address) other).url) && equalsNonHost((Address) other); }
public static boolean areUrlsEqual(String url1, String url2) { HttpUrl httpUrl1 = HttpUrl.parse(url1); HttpUrl httpUrl2 = HttpUrl.parse(url2); if(httpUrl1 == null && httpUrl2 == null) return false; // we're doomed anyway return httpUrl1 != null && httpUrl1.equals(httpUrl2); }
@Override public boolean equals(@Nullable Object other) { return other instanceof Address && url.equals(((Address) other).url) && equalsNonHost((Address) other); }
@Override public boolean equals(@Nullable Object other) { return other instanceof Address && url.equals(((Address) other).url) && equalsNonHost((Address) other); }
@Override public boolean isMatch(Request a, Request b) { return a.url().equals(b.url()); } }, host {
@Override public boolean equals(Object other) { if (other instanceof Address) { Address that = (Address) other; return this.url.equals(that.url) && this.dns.equals(that.dns) && this.authenticator.equals(that.authenticator) && this.protocols.equals(that.protocols) && this.connectionSpecs.equals(that.connectionSpecs) && this.proxySelector.equals(that.proxySelector) && equal(this.proxy, that.proxy) && equal(this.sslSocketFactory, that.sslSocketFactory) && equal(this.hostnameVerifier, that.hostnameVerifier) && equal(this.certificatePinner, that.certificatePinner); } return false; }
/** * Creates a new {@link UrlSelector} with the supplied URLs. The order of the URLs may be randomized by setting * {@code randomizeOrder} to true. If a {@code failedUrlCooldown} is specified, URLs that are marked as failed * using {@link #markAsFailed(HttpUrl)} will be removed from the pool of prioritized, healthy URLs for that period * of time. */ static UrlSelectorImpl createWithFailedUrlCooldown(Collection<String> baseUrls, boolean randomizeOrder, Duration failedUrlCooldown) { List<String> orderedUrls = new ArrayList<>(baseUrls); if (randomizeOrder) { Collections.shuffle(orderedUrls); } ImmutableSet.Builder<HttpUrl> canonicalUrls = ImmutableSet.builder(); // ImmutableSet maintains insert order orderedUrls.forEach(url -> { HttpUrl httpUrl = HttpUrl.parse(switchWsToHttp(url)); Preconditions.checkArgument(httpUrl != null, "Not a valid URL: %s", url); HttpUrl canonicalUrl = canonicalize(httpUrl); Preconditions.checkArgument(canonicalUrl.equals(httpUrl), "Base URLs must be 'canonical' and consist of schema, host, port, and path only: %s", url); canonicalUrls.add(canonicalUrl); }); return new UrlSelectorImpl(ImmutableList.copyOf(canonicalUrls.build()), failedUrlCooldown); }
@Override public boolean isMatch(Request a, Request b) { return a.url().equals(b.url()); } }, host {
/** * Creates a new {@link UrlSelector} with the supplied URLs. The order of the URLs may be randomized by setting * {@code randomizeOrder} to true. If a {@code failedUrlCooldown} is specified, URLs that are marked as failed * using {@link #markAsFailed(HttpUrl)} will be removed from the pool of prioritized, healthy URLs for that period * of time. */ static UrlSelectorImpl createWithFailedUrlCooldown(Collection<String> baseUrls, boolean randomizeOrder, Duration failedUrlCooldown) { List<String> orderedUrls = new ArrayList<>(baseUrls); if (randomizeOrder) { Collections.shuffle(orderedUrls); } ImmutableSet.Builder<HttpUrl> canonicalUrls = ImmutableSet.builder(); // ImmutableSet maintains insert order orderedUrls.forEach(url -> { HttpUrl httpUrl = HttpUrl.parse(switchWsToHttp(url)); Preconditions.checkArgument(httpUrl != null, "Not a valid URL: %s", url); HttpUrl canonicalUrl = canonicalize(httpUrl); Preconditions.checkArgument(canonicalUrl.equals(httpUrl), "Base URLs must be 'canonical' and consist of schema, host, port, and path only: %s", url); canonicalUrls.add(canonicalUrl); }); return new UrlSelectorImpl(ImmutableList.copyOf(canonicalUrls.build()), failedUrlCooldown); }
@Override public boolean isMatch(Request a, Request b) { return a.url().equals(b.url()); } }, host {
@Override public boolean equals(Object other) { if (other instanceof Address) { Address that = (Address) other; return this.url.equals(that.url) && this.dns.equals(that.dns) && this.authenticator.equals(that.authenticator) && this.protocols.equals(that.protocols) && this.connectionSpecs.equals(that.connectionSpecs) && this.proxySelector.equals(that.proxySelector) && equal(this.proxy, that.proxy) && equal(this.sslSocketFactory, that.sslSocketFactory) && equal(this.hostnameVerifier, that.hostnameVerifier) && equal(this.certificatePinner, that.certificatePinner); } return false; }
/** * Creates a new {@link UrlSelector} with the supplied URLs. The order of the URLs may be randomized by setting * {@code randomizeOrder} to true. If a {@code failedUrlCooldown} is specified, URLs that are marked as failed * using {@link #markAsFailed(HttpUrl)} will be removed from the pool of prioritized, healthy URLs for that period * of time. */ static UrlSelectorImpl createWithFailedUrlCooldown(Collection<String> baseUrls, boolean randomizeOrder, Duration failedUrlCooldown) { List<String> orderedUrls = new ArrayList<>(baseUrls); if (randomizeOrder) { Collections.shuffle(orderedUrls); } ImmutableSet.Builder<HttpUrl> canonicalUrls = ImmutableSet.builder(); // ImmutableSet maintains insert order orderedUrls.forEach(url -> { HttpUrl httpUrl = HttpUrl.parse(switchWsToHttp(url)); Preconditions.checkArgument(httpUrl != null, "Not a valid URL: %s", url); HttpUrl canonicalUrl = canonicalize(httpUrl); Preconditions.checkArgument(canonicalUrl.equals(httpUrl), "Base URLs must be 'canonical' and consist of schema, host, port, and path only: %s", url); canonicalUrls.add(canonicalUrl); }); return new UrlSelectorImpl(ImmutableList.copyOf(canonicalUrls.build()), failedUrlCooldown); }
@Override public boolean equals(Object other) { if (other instanceof Address) { Address that = (Address) other; return this.url.equals(that.url) && this.dns.equals(that.dns) && this.proxyAuthenticator.equals(that.proxyAuthenticator) && this.protocols.equals(that.protocols) && this.connectionSpecs.equals(that.connectionSpecs) && this.proxySelector.equals(that.proxySelector) && equal(this.proxy, that.proxy) && equal(this.sslSocketFactory, that.sslSocketFactory) && equal(this.hostnameVerifier, that.hostnameVerifier) && equal(this.certificatePinner, that.certificatePinner); } return false; }
@Override public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof OkHttpSender) { OkHttpSender that = (OkHttpSender) o; return (this.encoding.equals(that.encoding())) && (this.messageMaxBytes == that.messageMaxBytes()) && (this.endpoint.equals(that.endpoint())) && (this.client.equals(that.client())) && (this.maxRequests == that.maxRequests()) && (this.compressionEnabled == that.compressionEnabled()) && (this.encoder.equals(that.encoder())); } return false; }