SrgField.java
1.67 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
* This file is part of LiteLoader.
* Copyright (C) 2012-16 Adam Mummery-Smith
* All Rights Reserved.
*/
package com.mumfrey.liteloader.core.runtime;
import com.google.common.base.Objects;
/**
* Stores information about an SRG field mapping during AP runs
*/
public final class SrgField
{
private final String mapping;
public SrgField(String mapping)
{
this.mapping = mapping;
}
public String getName()
{
if (this.mapping == null)
{
return null;
}
int pos = this.mapping.lastIndexOf('/');
return pos > -1 ? this.mapping.substring(pos + 1) : this.mapping;
}
public String getOwner()
{
if (this.mapping == null)
{
return null;
}
int pos = this.mapping.lastIndexOf('/');
return pos > -1 ? this.mapping.substring(0, pos) : null;
}
public String getMapping()
{
return this.mapping;
}
public SrgField move(String newOwner)
{
return new SrgField((newOwner != null ? newOwner + "/" : "") + this.getName());
}
public SrgField copy()
{
return new SrgField(this.mapping);
}
@Override
public int hashCode()
{
return Objects.hashCode(this.mapping);
}
@Override
public boolean equals(Object obj)
{
if (this == obj)
{
return true;
}
if (obj instanceof SrgField)
{
return Objects.equal(this.mapping, ((SrgField)obj).mapping);
}
return false;
}
@Override
public String toString()
{
return this.mapping;
}
}