Origin implements Serializable { @Override public int hashCode() { if(SCHEME_HTTPS.equals(this.scheme) || SCHEME_HTTP.equals(this.scheme)){ return Objects.hash(scheme, host, port); } else { return Objects.hash(scheme, schemeSpecificPart); } } @Deprecated  Origin(String scheme, String host, int port);  Origin(String originUrl); static Origin create(String value); String getScheme(); String getHost(); Integer getPort(); String getSchemeSpecificPart(); @JsonValue @Override String toString(); @Override boolean equals(Object o); @Override int hashCode();  }
@Test @SuppressWarnings("deprecation") void hashCode_test() { Origin originA = new Origin("https: Origin originB = new Origin("https", "example.com", 443); Origin originC = new Origin("http: Origin originD = new Origin("http", "localhost", 8080); Origin android_apk_key_hash_abc123_a = new Origin("android:apk-key-hash:abc123"); Origin android_apk_key_hash_abc123_b = new Origin("android:apk-key-hash:abc123"); Origin android_apk_key_hash_def456 = new Origin("android:apk-key-hash:def"); Origin invalid_data = new Origin("invalid:data"); assertThat(originA).hasSameHashCodeAs(originB); assertThat(originC).hasSameHashCodeAs(originD); assertThat(android_apk_key_hash_abc123_a).hasSameHashCodeAs(android_apk_key_hash_abc123_b); assertThat(android_apk_key_hash_abc123_a.hashCode()).isNotEqualTo(android_apk_key_hash_def456.hashCode()); assertThat(android_apk_key_hash_abc123_a.hashCode()).isNotEqualTo(invalid_data.hashCode()); }