| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.security.net.config; |
| 18 |
|
| 19 |
import android.annotation.Nullable; |
| 20 |
|
| 21 |
import java.util.Locale; |
| 22 |
|
| 23 |
|
| 24 |
public final class Domain { |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
public final String hostname; |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
public final boolean subdomainsIncluded; |
| 34 |
|
| 35 |
public Domain(String hostname, boolean subdomainsIncluded) { |
| 36 |
if (hostname == null) { |
| 37 |
throw new NullPointerException("Hostname must not be null"); |
| 38 |
} |
| 39 |
this.hostname = hostname.toLowerCase(Locale.US); |
| 40 |
this.subdomainsIncluded = subdomainsIncluded; |
| 41 |
} |
| 42 |
|
| 43 |
@Override |
| 44 |
public int hashCode() { |
| 45 |
return hostname.hashCode() ^ (subdomainsIncluded ? 1231 : 1237); |
| 46 |
} |
| 47 |
|
| 48 |
@Override |
| 49 |
public boolean equals(@Nullable Object other) { |
| 50 |
if (other == this) { |
| 51 |
return true; |
| 52 |
} |
| 53 |
if (!(other instanceof Domain)) { |
| 54 |
return false; |
| 55 |
} |
| 56 |
Domain otherDomain = (Domain) other; |
| 57 |
return otherDomain.subdomainsIncluded == this.subdomainsIncluded && |
| 58 |
otherDomain.hostname.equals(this.hostname); |
| 59 |
} |
| 60 |
} |