mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2024-12-27 17:42:33 -06:00
75 lines
2.5 KiB
Java
75 lines
2.5 KiB
Java
package com.google.common.net;
|
|
|
|
import com.google.common.base.Preconditions;
|
|
import java.net.InetAddress;
|
|
import java.text.ParseException;
|
|
import javax.annotation.CheckForNull;
|
|
|
|
@ElementTypesAreNonnullByDefault
|
|
/* loaded from: classes3.dex */
|
|
public final class HostSpecifier {
|
|
private final String canonicalForm;
|
|
|
|
public String toString() {
|
|
return this.canonicalForm;
|
|
}
|
|
|
|
private HostSpecifier(String str) {
|
|
this.canonicalForm = str;
|
|
}
|
|
|
|
public static HostSpecifier fromValid(String str) {
|
|
InetAddress inetAddress;
|
|
HostAndPort fromString = HostAndPort.fromString(str);
|
|
Preconditions.checkArgument(!fromString.hasPort());
|
|
String host = fromString.getHost();
|
|
try {
|
|
inetAddress = InetAddresses.forString(host);
|
|
} catch (IllegalArgumentException unused) {
|
|
inetAddress = null;
|
|
}
|
|
if (inetAddress != null) {
|
|
return new HostSpecifier(InetAddresses.toUriString(inetAddress));
|
|
}
|
|
InternetDomainName from = InternetDomainName.from(host);
|
|
if (from.hasPublicSuffix()) {
|
|
return new HostSpecifier(from.toString());
|
|
}
|
|
String valueOf = String.valueOf(host);
|
|
throw new IllegalArgumentException(valueOf.length() != 0 ? "Domain name does not have a recognized public suffix: ".concat(valueOf) : new String("Domain name does not have a recognized public suffix: "));
|
|
}
|
|
|
|
public static HostSpecifier from(String str) throws ParseException {
|
|
try {
|
|
return fromValid(str);
|
|
} catch (IllegalArgumentException e) {
|
|
String valueOf = String.valueOf(str);
|
|
ParseException parseException = new ParseException(valueOf.length() != 0 ? "Invalid host specifier: ".concat(valueOf) : new String("Invalid host specifier: "), 0);
|
|
parseException.initCause(e);
|
|
throw parseException;
|
|
}
|
|
}
|
|
|
|
public static boolean isValid(String str) {
|
|
try {
|
|
fromValid(str);
|
|
return true;
|
|
} catch (IllegalArgumentException unused) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public boolean equals(@CheckForNull Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (obj instanceof HostSpecifier) {
|
|
return this.canonicalForm.equals(((HostSpecifier) obj).canonicalForm);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public int hashCode() {
|
|
return this.canonicalForm.hashCode();
|
|
}
|
|
}
|