-
-
Notifications
You must be signed in to change notification settings - Fork 30
/
StringHolder.java
39 lines (31 loc) · 990 Bytes
/
StringHolder.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package com.denizenscript.denizencore.utilities.text;
import com.denizenscript.denizencore.utilities.CoreUtilities;
/** Helper for case-insensitive strings that remember their original casing. */
public class StringHolder {
/** Input text with original casing. */
public final String str;
/** Input text, pre-lowercased. */
public final String low;
public StringHolder(String _str) {
str = _str;
low = CoreUtilities.toLowerCase(_str);
}
@Override
public int hashCode() {
return low.hashCode();
}
@Override
public boolean equals(Object obj) {
if (obj instanceof String) {
return CoreUtilities.equalsIgnoreCase(low, (String) obj);
}
else if (obj instanceof StringHolder) {
return low.equals(((StringHolder) obj).low);
}
return false;
}
@Override
public String toString() {
return str;
}
}