diff options
Diffstat (limited to 'src/cuchaz/enigma/mapping/ProcyonEntryFactory.java')
| -rw-r--r-- | src/cuchaz/enigma/mapping/ProcyonEntryFactory.java | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/cuchaz/enigma/mapping/ProcyonEntryFactory.java b/src/cuchaz/enigma/mapping/ProcyonEntryFactory.java new file mode 100644 index 0000000..777a12e --- /dev/null +++ b/src/cuchaz/enigma/mapping/ProcyonEntryFactory.java | |||
| @@ -0,0 +1,55 @@ | |||
| 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 | * | ||
| 8 | * Contributors: | ||
| 9 | * Jeff Martin - initial API and implementation | ||
| 10 | ******************************************************************************/ | ||
| 11 | package cuchaz.enigma.mapping; | ||
| 12 | |||
| 13 | import com.strobel.assembler.metadata.FieldDefinition; | ||
| 14 | import com.strobel.assembler.metadata.MethodDefinition; | ||
| 15 | |||
| 16 | |||
| 17 | public class ProcyonEntryFactory { | ||
| 18 | |||
| 19 | public static FieldEntry getFieldEntry(FieldDefinition def) { | ||
| 20 | return new FieldEntry( | ||
| 21 | new ClassEntry(def.getDeclaringType().getInternalName()), | ||
| 22 | def.getName(), | ||
| 23 | new Type(def.getErasedSignature()) | ||
| 24 | ); | ||
| 25 | } | ||
| 26 | |||
| 27 | public static MethodEntry getMethodEntry(MethodDefinition def) { | ||
| 28 | return new MethodEntry( | ||
| 29 | new ClassEntry(def.getDeclaringType().getInternalName()), | ||
| 30 | def.getName(), | ||
| 31 | new Signature(def.getErasedSignature()) | ||
| 32 | ); | ||
| 33 | } | ||
| 34 | |||
| 35 | public static ConstructorEntry getConstructorEntry(MethodDefinition def) { | ||
| 36 | if (def.isTypeInitializer()) { | ||
| 37 | return new ConstructorEntry( | ||
| 38 | new ClassEntry(def.getDeclaringType().getInternalName()) | ||
| 39 | ); | ||
| 40 | } else { | ||
| 41 | return new ConstructorEntry( | ||
| 42 | new ClassEntry(def.getDeclaringType().getInternalName()), | ||
| 43 | new Signature(def.getErasedSignature()) | ||
| 44 | ); | ||
| 45 | } | ||
| 46 | } | ||
| 47 | |||
| 48 | public static BehaviorEntry getBehaviorEntry(MethodDefinition def) { | ||
| 49 | if (def.isConstructor() || def.isTypeInitializer()) { | ||
| 50 | return getConstructorEntry(def); | ||
| 51 | } else { | ||
| 52 | return getMethodEntry(def); | ||
| 53 | } | ||
| 54 | } | ||
| 55 | } | ||