diff options
Diffstat (limited to 'src/main/java/cuchaz/enigma/mapping/LocalVariableMapping.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/mapping/LocalVariableMapping.java | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/main/java/cuchaz/enigma/mapping/LocalVariableMapping.java b/src/main/java/cuchaz/enigma/mapping/LocalVariableMapping.java new file mode 100644 index 0000000..62dbcf3 --- /dev/null +++ b/src/main/java/cuchaz/enigma/mapping/LocalVariableMapping.java | |||
| @@ -0,0 +1,53 @@ | |||
| 1 | /******************************************************************************* | ||
| 2 | * Copyright (c) 2015 Jeff Martin. | ||
| 3 | * All rights reserved. This program and the accompanying materials | ||
| 4 | * are made available under the terms of the GNU Lesser General Public | ||
| 5 | * License v3.0 which accompanies this distribution, and is available at | ||
| 6 | * http://www.gnu.org/licenses/lgpl.html | ||
| 7 | * <p> | ||
| 8 | * Contributors: | ||
| 9 | * Jeff Martin - initial API and implementation | ||
| 10 | ******************************************************************************/ | ||
| 11 | |||
| 12 | package cuchaz.enigma.mapping; | ||
| 13 | |||
| 14 | import cuchaz.enigma.mapping.entry.LocalVariableEntry; | ||
| 15 | import cuchaz.enigma.mapping.entry.MethodEntry; | ||
| 16 | |||
| 17 | public class LocalVariableMapping implements Comparable<LocalVariableMapping> { | ||
| 18 | |||
| 19 | private int index; | ||
| 20 | private String name; | ||
| 21 | |||
| 22 | // NOTE: this argument order is important for the MethodReader/MethodWriter | ||
| 23 | public LocalVariableMapping(int index, String name) { | ||
| 24 | this.index = index; | ||
| 25 | this.name = NameValidator.validateArgumentName(name); | ||
| 26 | } | ||
| 27 | |||
| 28 | public LocalVariableMapping(LocalVariableMapping other) { | ||
| 29 | this.index = other.index; | ||
| 30 | this.name = other.name; | ||
| 31 | } | ||
| 32 | |||
| 33 | public int getIndex() { | ||
| 34 | return this.index; | ||
| 35 | } | ||
| 36 | |||
| 37 | public String getName() { | ||
| 38 | return this.name; | ||
| 39 | } | ||
| 40 | |||
| 41 | public void setName(String val) { | ||
| 42 | this.name = NameValidator.validateArgumentName(val); | ||
| 43 | } | ||
| 44 | |||
| 45 | public LocalVariableEntry getObfEntry(MethodEntry methodEntry) { | ||
| 46 | return new LocalVariableEntry(methodEntry, index, name); | ||
| 47 | } | ||
| 48 | |||
| 49 | @Override | ||
| 50 | public int compareTo(LocalVariableMapping other) { | ||
| 51 | return Integer.compare(this.index, other.index); | ||
| 52 | } | ||
| 53 | } | ||