diff options
| author | 2014-08-04 00:26:48 -0400 | |
|---|---|---|
| committer | 2014-08-04 00:26:48 -0400 | |
| commit | 57f45b0409d5363782052183bb090175c469f89a (patch) | |
| tree | 672b32876b420445630e58e16b67d671e45c07b6 /src/cuchaz/enigma/mapping/ClassMapping.java | |
| parent | fixed bugs with saving mappings (diff) | |
| download | enigma-fork-57f45b0409d5363782052183bb090175c469f89a.tar.gz enigma-fork-57f45b0409d5363782052183bb090175c469f89a.tar.xz enigma-fork-57f45b0409d5363782052183bb090175c469f89a.zip | |
added stable save order for mappings to hopefully help with merging
added color-coding for source identifiers
redesigned rename GUI
customized editor pane, added popup menu
finished name validation
added last-chance save on window close
Diffstat (limited to 'src/cuchaz/enigma/mapping/ClassMapping.java')
| -rw-r--r-- | src/cuchaz/enigma/mapping/ClassMapping.java | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/src/cuchaz/enigma/mapping/ClassMapping.java b/src/cuchaz/enigma/mapping/ClassMapping.java index 3ba3569..a1cc775 100644 --- a/src/cuchaz/enigma/mapping/ClassMapping.java +++ b/src/cuchaz/enigma/mapping/ClassMapping.java | |||
| @@ -15,7 +15,7 @@ import java.util.Map; | |||
| 15 | 15 | ||
| 16 | import com.beust.jcommander.internal.Maps; | 16 | import com.beust.jcommander.internal.Maps; |
| 17 | 17 | ||
| 18 | public class ClassMapping implements Serializable | 18 | public class ClassMapping implements Serializable, Comparable<ClassMapping> |
| 19 | { | 19 | { |
| 20 | private static final long serialVersionUID = -5148491146902340107L; | 20 | private static final long serialVersionUID = -5148491146902340107L; |
| 21 | 21 | ||
| @@ -30,7 +30,7 @@ public class ClassMapping implements Serializable | |||
| 30 | public ClassMapping( String obfName, String deobfName ) | 30 | public ClassMapping( String obfName, String deobfName ) |
| 31 | { | 31 | { |
| 32 | m_obfName = obfName; | 32 | m_obfName = obfName; |
| 33 | m_deobfName = deobfName; | 33 | m_deobfName = NameValidator.validateClassName( deobfName ); |
| 34 | m_fieldsByObf = Maps.newHashMap(); | 34 | m_fieldsByObf = Maps.newHashMap(); |
| 35 | m_fieldsByDeobf = Maps.newHashMap(); | 35 | m_fieldsByDeobf = Maps.newHashMap(); |
| 36 | m_methodsByObf = Maps.newHashMap(); | 36 | m_methodsByObf = Maps.newHashMap(); |
| @@ -48,7 +48,7 @@ public class ClassMapping implements Serializable | |||
| 48 | } | 48 | } |
| 49 | public void setDeobfName( String val ) | 49 | public void setDeobfName( String val ) |
| 50 | { | 50 | { |
| 51 | m_deobfName = val; | 51 | m_deobfName = NameValidator.validateClassName( val ); |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | public Iterable<FieldMapping> fields( ) | 54 | public Iterable<FieldMapping> fields( ) |
| @@ -97,11 +97,6 @@ public class ClassMapping implements Serializable | |||
| 97 | 97 | ||
| 98 | public void setFieldName( String obfName, String deobfName ) | 98 | public void setFieldName( String obfName, String deobfName ) |
| 99 | { | 99 | { |
| 100 | if( deobfName == null ) | ||
| 101 | { | ||
| 102 | throw new IllegalArgumentException( "deobf name cannot be null!" ); | ||
| 103 | } | ||
| 104 | |||
| 105 | FieldMapping fieldMapping = m_fieldsByObf.get( obfName ); | 100 | FieldMapping fieldMapping = m_fieldsByObf.get( obfName ); |
| 106 | if( fieldMapping == null ) | 101 | if( fieldMapping == null ) |
| 107 | { | 102 | { |
| @@ -140,11 +135,6 @@ public class ClassMapping implements Serializable | |||
| 140 | 135 | ||
| 141 | public void setMethodNameAndSignature( String obfName, String obfSignature, String deobfName, String deobfSignature ) | 136 | public void setMethodNameAndSignature( String obfName, String obfSignature, String deobfName, String deobfSignature ) |
| 142 | { | 137 | { |
| 143 | if( deobfName == null ) | ||
| 144 | { | ||
| 145 | throw new IllegalArgumentException( "deobf name cannot be null!" ); | ||
| 146 | } | ||
| 147 | |||
| 148 | MethodMapping methodIndex = m_methodsByObf.get( getMethodKey( obfName, obfSignature ) ); | 138 | MethodMapping methodIndex = m_methodsByObf.get( getMethodKey( obfName, obfSignature ) ); |
| 149 | if( methodIndex == null ) | 139 | if( methodIndex == null ) |
| 150 | { | 140 | { |
| @@ -167,11 +157,6 @@ public class ClassMapping implements Serializable | |||
| 167 | 157 | ||
| 168 | public void setArgumentName( String obfMethodName, String obfMethodSignature, int argumentIndex, String argumentName ) | 158 | public void setArgumentName( String obfMethodName, String obfMethodSignature, int argumentIndex, String argumentName ) |
| 169 | { | 159 | { |
| 170 | if( argumentName == null ) | ||
| 171 | { | ||
| 172 | throw new IllegalArgumentException( "argument name cannot be null!" ); | ||
| 173 | } | ||
| 174 | |||
| 175 | MethodMapping methodIndex = m_methodsByObf.get( getMethodKey( obfMethodName, obfMethodSignature ) ); | 160 | MethodMapping methodIndex = m_methodsByObf.get( getMethodKey( obfMethodName, obfMethodSignature ) ); |
| 176 | if( methodIndex == null ) | 161 | if( methodIndex == null ) |
| 177 | { | 162 | { |
| @@ -214,4 +199,10 @@ public class ClassMapping implements Serializable | |||
| 214 | } | 199 | } |
| 215 | return buf.toString(); | 200 | return buf.toString(); |
| 216 | } | 201 | } |
| 202 | |||
| 203 | @Override | ||
| 204 | public int compareTo( ClassMapping other ) | ||
| 205 | { | ||
| 206 | return m_obfName.compareTo( other.m_obfName ); | ||
| 207 | } | ||
| 217 | } | 208 | } |