diff options
Diffstat (limited to 'src/cuchaz/enigma/mapping/ConstructorEntry.java')
| -rw-r--r-- | src/cuchaz/enigma/mapping/ConstructorEntry.java | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/src/cuchaz/enigma/mapping/ConstructorEntry.java b/src/cuchaz/enigma/mapping/ConstructorEntry.java new file mode 100644 index 0000000..e0fa7cf --- /dev/null +++ b/src/cuchaz/enigma/mapping/ConstructorEntry.java | |||
| @@ -0,0 +1,94 @@ | |||
| 1 | /******************************************************************************* | ||
| 2 | * Copyright (c) 2014 Jeff Martin. | ||
| 3 | * All rights reserved. This program and the accompanying materials | ||
| 4 | * are made available under the terms of the GNU Public License v3.0 | ||
| 5 | * which accompanies this distribution, and is available at | ||
| 6 | * http://www.gnu.org/licenses/gpl.html | ||
| 7 | * | ||
| 8 | * Contributors: | ||
| 9 | * Jeff Martin - initial API and implementation | ||
| 10 | ******************************************************************************/ | ||
| 11 | package cuchaz.enigma.mapping; | ||
| 12 | |||
| 13 | import java.io.Serializable; | ||
| 14 | |||
| 15 | import cuchaz.enigma.Util; | ||
| 16 | |||
| 17 | public class ConstructorEntry implements Entry, Serializable | ||
| 18 | { | ||
| 19 | private static final long serialVersionUID = -868346075317366758L; | ||
| 20 | |||
| 21 | private ClassEntry m_classEntry; | ||
| 22 | private String m_signature; | ||
| 23 | |||
| 24 | public ConstructorEntry( ClassEntry classEntry, String signature ) | ||
| 25 | { | ||
| 26 | if( classEntry == null ) | ||
| 27 | { | ||
| 28 | throw new IllegalArgumentException( "Class cannot be null!" ); | ||
| 29 | } | ||
| 30 | if( signature == null ) | ||
| 31 | { | ||
| 32 | throw new IllegalArgumentException( "Method signature cannot be null!" ); | ||
| 33 | } | ||
| 34 | |||
| 35 | m_classEntry = classEntry; | ||
| 36 | m_signature = signature; | ||
| 37 | } | ||
| 38 | |||
| 39 | public ConstructorEntry( ConstructorEntry other ) | ||
| 40 | { | ||
| 41 | m_classEntry = new ClassEntry( other.m_classEntry ); | ||
| 42 | m_signature = other.m_signature; | ||
| 43 | } | ||
| 44 | |||
| 45 | @Override | ||
| 46 | public ClassEntry getClassEntry( ) | ||
| 47 | { | ||
| 48 | return m_classEntry; | ||
| 49 | } | ||
| 50 | |||
| 51 | @Override | ||
| 52 | public String getName( ) | ||
| 53 | { | ||
| 54 | return m_classEntry.getName(); | ||
| 55 | } | ||
| 56 | |||
| 57 | public String getSignature( ) | ||
| 58 | { | ||
| 59 | return m_signature; | ||
| 60 | } | ||
| 61 | |||
| 62 | @Override | ||
| 63 | public String getClassName( ) | ||
| 64 | { | ||
| 65 | return m_classEntry.getName(); | ||
| 66 | } | ||
| 67 | |||
| 68 | @Override | ||
| 69 | public int hashCode( ) | ||
| 70 | { | ||
| 71 | return Util.combineHashesOrdered( m_classEntry, m_signature ); | ||
| 72 | } | ||
| 73 | |||
| 74 | @Override | ||
| 75 | public boolean equals( Object other ) | ||
| 76 | { | ||
| 77 | if( other instanceof ConstructorEntry ) | ||
| 78 | { | ||
| 79 | return equals( (ConstructorEntry)other ); | ||
| 80 | } | ||
| 81 | return false; | ||
| 82 | } | ||
| 83 | |||
| 84 | public boolean equals( ConstructorEntry other ) | ||
| 85 | { | ||
| 86 | return m_classEntry.equals( other.m_classEntry ) && m_signature.equals( other.m_signature ); | ||
| 87 | } | ||
| 88 | |||
| 89 | @Override | ||
| 90 | public String toString( ) | ||
| 91 | { | ||
| 92 | return m_classEntry.getName() + m_signature; | ||
| 93 | } | ||
| 94 | } | ||