diff options
Diffstat (limited to 'src/cuchaz/enigma/mapping/ConstructorEntry.java')
| -rw-r--r-- | src/cuchaz/enigma/mapping/ConstructorEntry.java | 99 |
1 files changed, 36 insertions, 63 deletions
diff --git a/src/cuchaz/enigma/mapping/ConstructorEntry.java b/src/cuchaz/enigma/mapping/ConstructorEntry.java index d99d1c3..ea0535f 100644 --- a/src/cuchaz/enigma/mapping/ConstructorEntry.java +++ b/src/cuchaz/enigma/mapping/ConstructorEntry.java | |||
| @@ -14,129 +14,102 @@ import java.io.Serializable; | |||
| 14 | 14 | ||
| 15 | import cuchaz.enigma.Util; | 15 | import cuchaz.enigma.Util; |
| 16 | 16 | ||
| 17 | public class ConstructorEntry implements BehaviorEntry, Serializable | 17 | public class ConstructorEntry implements BehaviorEntry, Serializable { |
| 18 | { | 18 | |
| 19 | private static final long serialVersionUID = -868346075317366758L; | 19 | private static final long serialVersionUID = -868346075317366758L; |
| 20 | 20 | ||
| 21 | private ClassEntry m_classEntry; | 21 | private ClassEntry m_classEntry; |
| 22 | private String m_signature; | 22 | private String m_signature; |
| 23 | 23 | ||
| 24 | public ConstructorEntry( ClassEntry classEntry ) | 24 | public ConstructorEntry(ClassEntry classEntry) { |
| 25 | { | 25 | this(classEntry, null); |
| 26 | this( classEntry, null ); | ||
| 27 | } | 26 | } |
| 28 | 27 | ||
| 29 | public ConstructorEntry( ClassEntry classEntry, String signature ) | 28 | public ConstructorEntry(ClassEntry classEntry, String signature) { |
| 30 | { | 29 | if (classEntry == null) { |
| 31 | if( classEntry == null ) | 30 | throw new IllegalArgumentException("Class cannot be null!"); |
| 32 | { | ||
| 33 | throw new IllegalArgumentException( "Class cannot be null!" ); | ||
| 34 | } | 31 | } |
| 35 | 32 | ||
| 36 | m_classEntry = classEntry; | 33 | m_classEntry = classEntry; |
| 37 | m_signature = signature; | 34 | m_signature = signature; |
| 38 | } | 35 | } |
| 39 | 36 | ||
| 40 | public ConstructorEntry( ConstructorEntry other ) | 37 | public ConstructorEntry(ConstructorEntry other) { |
| 41 | { | 38 | m_classEntry = new ClassEntry(other.m_classEntry); |
| 42 | m_classEntry = new ClassEntry( other.m_classEntry ); | ||
| 43 | m_signature = other.m_signature; | 39 | m_signature = other.m_signature; |
| 44 | } | 40 | } |
| 45 | 41 | ||
| 46 | public ConstructorEntry( ConstructorEntry other, String newClassName ) | 42 | public ConstructorEntry(ConstructorEntry other, String newClassName) { |
| 47 | { | 43 | m_classEntry = new ClassEntry(newClassName); |
| 48 | m_classEntry = new ClassEntry( newClassName ); | ||
| 49 | m_signature = other.m_signature; | 44 | m_signature = other.m_signature; |
| 50 | } | 45 | } |
| 51 | 46 | ||
| 52 | @Override | 47 | @Override |
| 53 | public ClassEntry getClassEntry( ) | 48 | public ClassEntry getClassEntry() { |
| 54 | { | ||
| 55 | return m_classEntry; | 49 | return m_classEntry; |
| 56 | } | 50 | } |
| 57 | 51 | ||
| 58 | @Override | 52 | @Override |
| 59 | public String getName( ) | 53 | public String getName() { |
| 60 | { | 54 | if (isStatic()) { |
| 61 | if( isStatic() ) | ||
| 62 | { | ||
| 63 | return "<clinit>"; | 55 | return "<clinit>"; |
| 64 | } | 56 | } |
| 65 | return "<init>"; | 57 | return "<init>"; |
| 66 | } | 58 | } |
| 67 | 59 | ||
| 68 | public boolean isStatic( ) | 60 | public boolean isStatic() { |
| 69 | { | ||
| 70 | return m_signature == null; | 61 | return m_signature == null; |
| 71 | } | 62 | } |
| 72 | 63 | ||
| 73 | @Override | 64 | @Override |
| 74 | public String getSignature( ) | 65 | public String getSignature() { |
| 75 | { | ||
| 76 | return m_signature; | 66 | return m_signature; |
| 77 | } | 67 | } |
| 78 | 68 | ||
| 79 | @Override | 69 | @Override |
| 80 | public String getClassName( ) | 70 | public String getClassName() { |
| 81 | { | ||
| 82 | return m_classEntry.getName(); | 71 | return m_classEntry.getName(); |
| 83 | } | 72 | } |
| 84 | 73 | ||
| 85 | @Override | 74 | @Override |
| 86 | public ConstructorEntry cloneToNewClass( ClassEntry classEntry ) | 75 | public ConstructorEntry cloneToNewClass(ClassEntry classEntry) { |
| 87 | { | 76 | return new ConstructorEntry(this, classEntry.getName()); |
| 88 | return new ConstructorEntry( this, classEntry.getName() ); | ||
| 89 | } | 77 | } |
| 90 | 78 | ||
| 91 | @Override | 79 | @Override |
| 92 | public int hashCode( ) | 80 | public int hashCode() { |
| 93 | { | 81 | if (isStatic()) { |
| 94 | if( isStatic() ) | 82 | return Util.combineHashesOrdered(m_classEntry); |
| 95 | { | 83 | } else { |
| 96 | return Util.combineHashesOrdered( m_classEntry ); | 84 | return Util.combineHashesOrdered(m_classEntry, m_signature); |
| 97 | } | ||
| 98 | else | ||
| 99 | { | ||
| 100 | return Util.combineHashesOrdered( m_classEntry, m_signature ); | ||
| 101 | } | 85 | } |
| 102 | } | 86 | } |
| 103 | 87 | ||
| 104 | @Override | 88 | @Override |
| 105 | public boolean equals( Object other ) | 89 | public boolean equals(Object other) { |
| 106 | { | 90 | if (other instanceof ConstructorEntry) { |
| 107 | if( other instanceof ConstructorEntry ) | 91 | return equals((ConstructorEntry)other); |
| 108 | { | ||
| 109 | return equals( (ConstructorEntry)other ); | ||
| 110 | } | 92 | } |
| 111 | return false; | 93 | return false; |
| 112 | } | 94 | } |
| 113 | 95 | ||
| 114 | public boolean equals( ConstructorEntry other ) | 96 | public boolean equals(ConstructorEntry other) { |
| 115 | { | 97 | if (isStatic() != other.isStatic()) { |
| 116 | if( isStatic() != other.isStatic() ) | ||
| 117 | { | ||
| 118 | return false; | 98 | return false; |
| 119 | } | 99 | } |
| 120 | 100 | ||
| 121 | if( isStatic() ) | 101 | if (isStatic()) { |
| 122 | { | 102 | return m_classEntry.equals(other.m_classEntry); |
| 123 | return m_classEntry.equals( other.m_classEntry ); | 103 | } else { |
| 124 | } | 104 | return m_classEntry.equals(other.m_classEntry) && m_signature.equals(other.m_signature); |
| 125 | else | ||
| 126 | { | ||
| 127 | return m_classEntry.equals( other.m_classEntry ) && m_signature.equals( other.m_signature ); | ||
| 128 | } | 105 | } |
| 129 | } | 106 | } |
| 130 | 107 | ||
| 131 | @Override | 108 | @Override |
| 132 | public String toString( ) | 109 | public String toString() { |
| 133 | { | 110 | if (isStatic()) { |
| 134 | if( isStatic() ) | ||
| 135 | { | ||
| 136 | return m_classEntry.getName() + "." + getName(); | 111 | return m_classEntry.getName() + "." + getName(); |
| 137 | } | 112 | } else { |
| 138 | else | ||
| 139 | { | ||
| 140 | return m_classEntry.getName() + "." + getName() + m_signature; | 113 | return m_classEntry.getName() + "." + getName() + m_signature; |
| 141 | } | 114 | } |
| 142 | } | 115 | } |