diff options
| author | 2017-05-16 00:24:29 +0200 | |
|---|---|---|
| committer | 2017-05-16 00:24:29 +0200 | |
| commit | b280104d2f926ab74772cef2bf1602663cefa312 (patch) | |
| tree | d130c86a30ec5df37b3a9c4bab576e971ae2e664 /src/main/java/cuchaz/enigma/convert/ClassMatch.java | |
| parent | Add offset for Enum constructor arguments (Fix #58) (diff) | |
| download | enigma-fork-b280104d2f926ab74772cef2bf1602663cefa312.tar.gz enigma-fork-b280104d2f926ab74772cef2bf1602663cefa312.tar.xz enigma-fork-b280104d2f926ab74772cef2bf1602663cefa312.zip | |
Remove the converter + some reorganization
Diffstat (limited to 'src/main/java/cuchaz/enigma/convert/ClassMatch.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/convert/ClassMatch.java | 83 |
1 files changed, 0 insertions, 83 deletions
diff --git a/src/main/java/cuchaz/enigma/convert/ClassMatch.java b/src/main/java/cuchaz/enigma/convert/ClassMatch.java deleted file mode 100644 index bb3e4f4..0000000 --- a/src/main/java/cuchaz/enigma/convert/ClassMatch.java +++ /dev/null | |||
| @@ -1,83 +0,0 @@ | |||
| 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.convert; | ||
| 13 | |||
| 14 | import com.google.common.collect.Sets; | ||
| 15 | import cuchaz.enigma.mapping.ClassEntry; | ||
| 16 | import cuchaz.enigma.utils.Utils; | ||
| 17 | |||
| 18 | import java.util.Collection; | ||
| 19 | import java.util.Set; | ||
| 20 | |||
| 21 | public class ClassMatch { | ||
| 22 | |||
| 23 | public Set<ClassEntry> sourceClasses; | ||
| 24 | public Set<ClassEntry> destClasses; | ||
| 25 | |||
| 26 | public ClassMatch(Collection<ClassEntry> sourceClasses, Collection<ClassEntry> destClasses) { | ||
| 27 | this.sourceClasses = Sets.newHashSet(sourceClasses); | ||
| 28 | this.destClasses = Sets.newHashSet(destClasses); | ||
| 29 | } | ||
| 30 | |||
| 31 | public ClassMatch(ClassEntry sourceClass, ClassEntry destClass) { | ||
| 32 | sourceClasses = Sets.newHashSet(); | ||
| 33 | if (sourceClass != null) { | ||
| 34 | sourceClasses.add(sourceClass); | ||
| 35 | } | ||
| 36 | destClasses = Sets.newHashSet(); | ||
| 37 | if (destClass != null) { | ||
| 38 | destClasses.add(destClass); | ||
| 39 | } | ||
| 40 | } | ||
| 41 | |||
| 42 | public boolean isMatched() { | ||
| 43 | return !sourceClasses.isEmpty() && !destClasses.isEmpty(); | ||
| 44 | } | ||
| 45 | |||
| 46 | public boolean isAmbiguous() { | ||
| 47 | return sourceClasses.size() > 1 || destClasses.size() > 1; | ||
| 48 | } | ||
| 49 | |||
| 50 | public ClassEntry getUniqueSource() { | ||
| 51 | if (sourceClasses.size() != 1) { | ||
| 52 | throw new IllegalStateException("Match has ambiguous source!"); | ||
| 53 | } | ||
| 54 | return sourceClasses.iterator().next(); | ||
| 55 | } | ||
| 56 | |||
| 57 | public ClassEntry getUniqueDest() { | ||
| 58 | if (destClasses.size() != 1) { | ||
| 59 | throw new IllegalStateException("Match has ambiguous source!"); | ||
| 60 | } | ||
| 61 | return destClasses.iterator().next(); | ||
| 62 | } | ||
| 63 | |||
| 64 | public Set<ClassEntry> intersectSourceClasses(Set<ClassEntry> classes) { | ||
| 65 | Set<ClassEntry> intersection = Sets.newHashSet(sourceClasses); | ||
| 66 | intersection.retainAll(classes); | ||
| 67 | return intersection; | ||
| 68 | } | ||
| 69 | |||
| 70 | @Override | ||
| 71 | public int hashCode() { | ||
| 72 | return Utils.combineHashesOrdered(sourceClasses, destClasses); | ||
| 73 | } | ||
| 74 | |||
| 75 | @Override | ||
| 76 | public boolean equals(Object other) { | ||
| 77 | return other instanceof ClassMatch && equals((ClassMatch) other); | ||
| 78 | } | ||
| 79 | |||
| 80 | public boolean equals(ClassMatch other) { | ||
| 81 | return this.sourceClasses.equals(other.sourceClasses) && this.destClasses.equals(other.destClasses); | ||
| 82 | } | ||
| 83 | } | ||