blob: d4499ab1274180a404f1a99bb53c7118921d4474 (
plain)
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
40
41
42
|
package at.hannibal2.skyhanni.utils
class NEUInternalName private constructor(private val internalName: String) {
companion object {
private val map = mutableMapOf<String, NEUInternalName>()
val NONE = "NONE".asInternalName()
val MISSING_ITEM = "MISSING_ITEM".asInternalName()
fun String.asInternalName(): NEUInternalName {
val internalName = uppercase()
return map.getOrPut(internalName) { NEUInternalName(internalName) }
}
fun fromItemName(itemName: String) = NEUItems.getInternalNameFromItemName(itemName)
}
fun asString() = internalName
override fun equals(other: Any?): Boolean {
if (other is NEUInternalName) {
return internalName == other.internalName
}
return super.equals(other)
}
override fun toString(): String = "internalName:$internalName"
override fun hashCode(): Int = internalName.hashCode()
fun equals(other: String) = internalName == other
fun contains(other: String) = internalName.contains(other)
fun startsWith(other: String) = internalName.startsWith(other)
fun endsWith(other: String) = internalName.endsWith(other)
fun replace(oldValue: String, newValue: String) =
internalName.replace(oldValue.uppercase(), newValue.uppercase()).asInternalName()
}
|