diff options
| author | 2016-08-17 18:35:12 +0200 | |
|---|---|---|
| committer | 2016-08-17 18:35:12 +0200 | |
| commit | 5540c815de36e316d0749ce2163f12c61895b327 (patch) | |
| tree | 2b30d5ae98735ee7cba7d1c0087c51d68ed3ebf9 /src/main/java/cuchaz/enigma/convert/ClassNamer.java | |
| parent | Revert "Removed util" (diff) | |
| download | enigma-fork-5540c815de36e316d0749ce2163f12c61895b327.tar.gz enigma-fork-5540c815de36e316d0749ce2163f12c61895b327.tar.xz enigma-fork-5540c815de36e316d0749ce2163f12c61895b327.zip | |
Revert "Removed unused methods"
This reverts commit 1742190f784d0d62e7cc869eebafdfe1927e448f.
Diffstat (limited to 'src/main/java/cuchaz/enigma/convert/ClassNamer.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/convert/ClassNamer.java | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/main/java/cuchaz/enigma/convert/ClassNamer.java b/src/main/java/cuchaz/enigma/convert/ClassNamer.java new file mode 100644 index 0000000..e471c7d --- /dev/null +++ b/src/main/java/cuchaz/enigma/convert/ClassNamer.java | |||
| @@ -0,0 +1,56 @@ | |||
| 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 | package cuchaz.enigma.convert; | ||
| 12 | |||
| 13 | import com.google.common.collect.BiMap; | ||
| 14 | import com.google.common.collect.Maps; | ||
| 15 | |||
| 16 | import java.util.Map; | ||
| 17 | |||
| 18 | import cuchaz.enigma.mapping.ClassEntry; | ||
| 19 | |||
| 20 | public class ClassNamer { | ||
| 21 | |||
| 22 | public interface SidedClassNamer { | ||
| 23 | String getName(String name); | ||
| 24 | } | ||
| 25 | |||
| 26 | private Map<String, String> sourceNames; | ||
| 27 | private Map<String, String> destNames; | ||
| 28 | |||
| 29 | public ClassNamer(BiMap<ClassEntry, ClassEntry> mappings) { | ||
| 30 | // convert the identity mappings to name maps | ||
| 31 | this.sourceNames = Maps.newHashMap(); | ||
| 32 | this.destNames = Maps.newHashMap(); | ||
| 33 | int i = 0; | ||
| 34 | for (Map.Entry<ClassEntry, ClassEntry> entry : mappings.entrySet()) { | ||
| 35 | String name = String.format("M%04d", i++); | ||
| 36 | this.sourceNames.put(entry.getKey().getName(), name); | ||
| 37 | this.destNames.put(entry.getValue().getName(), name); | ||
| 38 | } | ||
| 39 | } | ||
| 40 | |||
| 41 | public String getSourceName(String name) { | ||
| 42 | return this.sourceNames.get(name); | ||
| 43 | } | ||
| 44 | |||
| 45 | public String getDestName(String name) { | ||
| 46 | return this.destNames.get(name); | ||
| 47 | } | ||
| 48 | |||
| 49 | public SidedClassNamer getSourceNamer() { | ||
| 50 | return this::getSourceName; | ||
| 51 | } | ||
| 52 | |||
| 53 | public SidedClassNamer getDestNamer() { | ||
| 54 | return this::getDestName; | ||
| 55 | } | ||
| 56 | } | ||