MCPcopy Create free account
hub / github.com/M66B/FairEmail / equals

Method equals

app/src/main/java/javax/mail/URLName.java:419–467  ·  view source on GitHub ↗

Compares two URLNames. The result is true if and only if the argument is not null and is a URLName object that represents the same URLName as this object. Two URLName objects are equal if they have the same protocol and the same host, the same port number on the host, the same username, and the same

(Object obj)

Source from the content-addressed store, hash-verified

417 * nor is any reference field appended to the filename.
418 */
419 @Override
420 public boolean equals(Object obj) {
421 if (!(obj instanceof URLName))
422 return false;
423 URLName u2 = (URLName)obj;
424
425 // compare protocols
426 if (!(protocol == u2.protocol ||
427 (protocol != null && protocol.equals(u2.protocol))))
428 return false;
429
430 // compare hosts
431 InetAddress a1 = getHostAddress(), a2 = u2.getHostAddress();
432 // if we have internet address for both, and they're not the same, fail
433 if (a1 != null && a2 != null) {
434 if (!a1.equals(a2))
435 return false;
436 // else, if we have host names for both, and they're not the same, fail
437 } else if (host != null && u2.host != null) {
438 if (!host.equalsIgnoreCase(u2.host))
439 return false;
440 // else, if not both null
441 } else if (host != u2.host) {
442 return false;
443 }
444 // at this point, hosts match
445
446 // compare usernames
447 if (!(username == u2.username ||
448 (username != null && username.equals(u2.username))))
449 return false;
450
451 // Forget about password since it doesn't
452 // really denote a different store.
453
454 // compare files
455 String f1 = file == null ? "" : file;
456 String f2 = u2.file == null ? "" : u2.file;
457
458 if (!f1.equals(f2))
459 return false;
460
461 // compare ports
462 if (port != u2.port)
463 return false;
464
465 // all comparisons succeeded, they're equal
466 return true;
467 }
468
469 /**
470 * Compute the hash code for this URLName.

Callers

nothing calls this directly

Calls 1

getHostAddressMethod · 0.95

Tested by

no test coverage detected