summaryrefslogtreecommitdiff
path: root/src/main/java/ftbsc/lll/mapper/data/MethodSignature.java
blob: d7515a8b2cbcc86fbf32f3cbc6ee4b1b2edd030b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package ftbsc.lll.mapper.data;

import java.util.Objects;

/**
 * Container class for method signature data.
 */
public class MethodSignature {
   /**
    * The name of the method.
    */
   public final String name;

   /**
    * The descriptor of the method.
    */
   public final String descriptor;

   /**
    * Constructs a new {@link MethodSignature}. The parameters should be
    * either plain or obfuscated in the same way;
    * @param name       the method name
    * @param descriptor the method descriptor
    */
   public MethodSignature(String name, String descriptor) {
      this.name = name;
      this.descriptor = descriptor;
   }

   /**
    * Checks if two {@link MethodSignature}s represent the same method.
    * @param o the other signature
    * @return whether they represent the same method
    */
   @Override
   public boolean equals(Object o) {
      if(this == o) return true;
      if(o == null || getClass() != o.getClass()) return false;
      MethodSignature signature = (MethodSignature) o;
      return Objects.equals(name, signature.name) && Objects.equals(descriptor, signature.descriptor);
   }

   /**
    * Calculates a hash based on name and descriptor.
    * @return the hash code
    */
   @Override
   public int hashCode() {
      return Objects.hash(name, descriptor);
   }
}