mirror of
https://github.com/corda/corda.git
synced 2025-01-01 10:46:46 +00:00
check identities in String.equals(), etc.
This commit is contained in:
parent
b56eed68be
commit
6ddb8c839c
@ -65,14 +65,16 @@ public final class String implements Comparable<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
return o instanceof String && compareTo((String) o) == 0;
|
return this == o || (o instanceof String && compareTo((String) o) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean equalsIgnoreCase(String s) {
|
public boolean equalsIgnoreCase(String s) {
|
||||||
return compareToIgnoreCase(s) == 0;
|
return this == s || compareToIgnoreCase(s) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int compareTo(String s) {
|
public int compareTo(String s) {
|
||||||
|
if (this == s) return 0;
|
||||||
|
|
||||||
int d = length - s.length;
|
int d = length - s.length;
|
||||||
if (d != 0) {
|
if (d != 0) {
|
||||||
return d;
|
return d;
|
||||||
@ -88,6 +90,8 @@ public final class String implements Comparable<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int compareToIgnoreCase(String s) {
|
public int compareToIgnoreCase(String s) {
|
||||||
|
if (this == s) return 0;
|
||||||
|
|
||||||
int d = length - s.length;
|
int d = length - s.length;
|
||||||
if (d != 0) {
|
if (d != 0) {
|
||||||
return d;
|
return d;
|
||||||
|
Loading…
Reference in New Issue
Block a user