From e3f452250e51b7271f3989c7dfd12e4422934942 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Thu, 21 May 2015 23:30:00 +0100 Subject: Support Gradle alongside SSJB This makes builds faster, simpler and better automated but still keeps Cuchaz happy. :) --- src/cuchaz/enigma/convert/ClassForest.java | 60 ++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/cuchaz/enigma/convert/ClassForest.java (limited to 'src/cuchaz/enigma/convert/ClassForest.java') diff --git a/src/cuchaz/enigma/convert/ClassForest.java b/src/cuchaz/enigma/convert/ClassForest.java new file mode 100644 index 0000000..0407730 --- /dev/null +++ b/src/cuchaz/enigma/convert/ClassForest.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright (c) 2015 Jeff Martin. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser General Public + * License v3.0 which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl.html + * + * Contributors: + * Jeff Martin - initial API and implementation + ******************************************************************************/ +package cuchaz.enigma.convert; + +import java.util.Collection; + +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; + +import cuchaz.enigma.mapping.ClassEntry; + + +public class ClassForest { + + private ClassIdentifier m_identifier; + private Multimap m_forest; + + public ClassForest(ClassIdentifier identifier) { + m_identifier = identifier; + m_forest = HashMultimap.create(); + } + + public void addAll(Iterable entries) { + for (ClassEntry entry : entries) { + add(entry); + } + } + + public void add(ClassEntry entry) { + try { + m_forest.put(m_identifier.identify(entry), entry); + } catch (ClassNotFoundException ex) { + throw new Error("Unable to find class " + entry.getName()); + } + } + + public Collection identities() { + return m_forest.keySet(); + } + + public Collection classes() { + return m_forest.values(); + } + + public Collection getClasses(ClassIdentity identity) { + return m_forest.get(identity); + } + + public boolean containsIdentity(ClassIdentity identity) { + return m_forest.containsKey(identity); + } +} -- cgit v1.2.3