View Javadoc
1   package com.puppycrawl.tools.checkstyle.checks.coding.equalshashcode;
2   
3   public class InputEqualsHashCodeEqualsParameter {
4       public static class TestClass1 { // no violation
5           public boolean equals(String o) {
6               return true;
7           }
8       }
9       public static class TestClass2 { // violation, no correct `equals`
10          public int hashCode() {
11              return 1;
12          }
13          public boolean equals(String o) {
14              return true;
15          }
16      }
17      public static class TestClass3 { // violation, no `hashCode`
18          public boolean equals(Object o) {
19              return true;
20          }
21          public boolean equals(String o) {
22              return false;
23          }
24      }
25      public static class TestClass4 { // no violation
26          public int hashCode() {
27              return 1;
28          }
29          public boolean equals(Object o) {
30              return true;
31          }
32          public boolean equals(String o) {
33              return false;
34          }
35      }
36      public static class TestClass5 { // no violation
37          public int hashCode() {
38              return 1;
39          }
40          public boolean equals(java.lang.Object o) {
41              return true;
42          }
43      }
44      public static class TestClass6 { // violation, no `hashCode` implementation
45          public static int hashCode(int i) {
46              return 1;
47          }
48          public boolean equals(Object o) {
49              return true;
50          }
51      }
52      public static class TestClass7 { // violation, no `equals` implementation
53          public int hashCode() {
54              return 1;
55          }
56          public static boolean equals(Object o, Object o2) {
57              return true;
58          }
59      }
60      public static class TestClass8 { // no violation
61          public native int hashCode();
62          public native boolean equals(Object o);
63      }
64      public static class TestClass9 { // violation, no `equals` implementation
65          public native int hashCode();
66      }
67      public static class TestClass10 { // violation, no `hashCode` implementation
68          public native boolean equals(Object o);
69      }
70      public static abstract class TestClass11 { // no violation
71          public abstract int hashCode();
72          public abstract boolean equals(Object o);
73      }
74      public static abstract class TestClass12 { // violation, no `equals` implementation
75          public int hashCode() {
76              return 1;
77          }
78          public abstract boolean equals(Object o);
79      }
80      public static abstract class TestClass13 { // violation, no `hashCode` implementation
81          public abstract int hashCode();
82          public boolean equals(java.lang.Object o) {
83              return true;
84          }
85      }
86      public interface TestClass14 { // no violation
87          public int hashCode();
88          public boolean equals(Object o);
89      }
90      public interface TestClass15 { // no violation
91          public boolean equals(Object o);
92      }
93      public interface TestClass16 { // no violation
94          public int hashCode();
95      }
96  }