summaryrefslogtreecommitdiff
path: root/src/cuchaz/enigma/mapping/ConstructorEntry.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/cuchaz/enigma/mapping/ConstructorEntry.java')
-rw-r--r--src/cuchaz/enigma/mapping/ConstructorEntry.java54
1 files changed, 45 insertions, 9 deletions
diff --git a/src/cuchaz/enigma/mapping/ConstructorEntry.java b/src/cuchaz/enigma/mapping/ConstructorEntry.java
index 0f7dab6..ad029e1 100644
--- a/src/cuchaz/enigma/mapping/ConstructorEntry.java
+++ b/src/cuchaz/enigma/mapping/ConstructorEntry.java
@@ -21,16 +21,17 @@ public class ConstructorEntry implements BehaviorEntry, Serializable
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 )
25 {
26 this( classEntry, null );
27 }
28
24 public ConstructorEntry( ClassEntry classEntry, String signature ) 29 public ConstructorEntry( ClassEntry classEntry, String signature )
25 { 30 {
26 if( classEntry == null ) 31 if( classEntry == null )
27 { 32 {
28 throw new IllegalArgumentException( "Class cannot be null!" ); 33 throw new IllegalArgumentException( "Class cannot be null!" );
29 } 34 }
30 if( signature == null )
31 {
32 throw new IllegalArgumentException( "Method signature cannot be null!" );
33 }
34 35
35 m_classEntry = classEntry; 36 m_classEntry = classEntry;
36 m_signature = signature; 37 m_signature = signature;
@@ -47,11 +48,20 @@ public class ConstructorEntry implements BehaviorEntry, Serializable
47 { 48 {
48 return m_classEntry; 49 return m_classEntry;
49 } 50 }
50 51
51 @Override 52 @Override
52 public String getName( ) 53 public String getName( )
53 { 54 {
54 return m_classEntry.getName(); 55 if( isStatic() )
56 {
57 return "<clinit>";
58 }
59 return "<init>";
60 }
61
62 public boolean isStatic( )
63 {
64 return m_signature == null;
55 } 65 }
56 66
57 @Override 67 @Override
@@ -69,7 +79,14 @@ public class ConstructorEntry implements BehaviorEntry, Serializable
69 @Override 79 @Override
70 public int hashCode( ) 80 public int hashCode( )
71 { 81 {
72 return Util.combineHashesOrdered( m_classEntry, m_signature ); 82 if( isStatic() )
83 {
84 return Util.combineHashesOrdered( m_classEntry );
85 }
86 else
87 {
88 return Util.combineHashesOrdered( m_classEntry, m_signature );
89 }
73 } 90 }
74 91
75 @Override 92 @Override
@@ -84,12 +101,31 @@ public class ConstructorEntry implements BehaviorEntry, Serializable
84 101
85 public boolean equals( ConstructorEntry other ) 102 public boolean equals( ConstructorEntry other )
86 { 103 {
87 return m_classEntry.equals( other.m_classEntry ) && m_signature.equals( other.m_signature ); 104 if( isStatic() != other.isStatic() )
105 {
106 return false;
107 }
108
109 if( isStatic() )
110 {
111 return m_classEntry.equals( other.m_classEntry );
112 }
113 else
114 {
115 return m_classEntry.equals( other.m_classEntry ) && m_signature.equals( other.m_signature );
116 }
88 } 117 }
89 118
90 @Override 119 @Override
91 public String toString( ) 120 public String toString( )
92 { 121 {
93 return m_classEntry.getName() + m_signature; 122 if( isStatic() )
123 {
124 return m_classEntry.getName() + "." + getName();
125 }
126 else
127 {
128 return m_classEntry.getName() + "." + getName() + m_signature;
129 }
94 } 130 }
95} 131}