1
2
3
4
5
6
7 package com.puppycrawl.tools.checkstyle.checks.coding.equalshashcode;
8
9 import java.awt.*;
10 import java.io.ByteArrayOutputStream;
11 import java.io.File;
12
13
14
15
16
17 class InputEqualsHashCodeSemantic
18 {
19
20 static {
21 Boolean x = new Boolean(true);
22 }
23
24
25 {
26 Boolean x = new Boolean(true);
27 Boolean[] y = new Boolean[]{Boolean.TRUE, Boolean.FALSE};
28 }
29
30
31 Boolean getBoolean()
32 {
33 return new Boolean(true);
34 }
35
36 void otherInstantiations()
37 {
38
39 Object o1 = new InputBraces();
40 Object o2 = new InputModifier();
41
42 ByteArrayOutputStream s = new ByteArrayOutputStream();
43 File f = new File("/tmp");
44
45 Dimension dim = new Dimension();
46 Color col = new Color(0, 0, 0);
47 }
48
49 public class EqualsVsHashCode1
50 {
51 public boolean equals(int a)
52 {
53 return a == 1;
54 }
55 }
56
57 public class EqualsVsHashCode2
58 {
59 public boolean equals(String a)
60 {
61 return true;
62 }
63 }
64
65 public class EqualsVsHashCode3
66 {
67 public boolean equals(Object a)
68 {
69 return true;
70 }
71
72 public int hashCode()
73 {
74 return 0;
75 }
76 }
77
78 public class EqualsVsHashCode4
79 {
80
81 ByteArrayOutputStream bos1 = new ByteArrayOutputStream()
82 {
83 public boolean equals(Object a)
84 {
85 return true;
86 }
87
88 public int hashCode()
89 {
90 return 0;
91 }
92 };
93
94 ByteArrayOutputStream bos2 = new ByteArrayOutputStream()
95 {
96 public boolean equals(Object a)
97 {
98 return true;
99 }
100 };
101 }
102
103 public void triggerEmptyBlockWithoutBlock()
104 {
105
106 if (true)
107 return;
108 }
109
110
111 {
112 }
113
114 public class EqualsVsHashCode5
115 {
116 public <A> boolean equals(int a)
117 {
118 return a == 1;
119 }
120 }
121
122 public class EqualsVsHashCode6
123 {
124 public <A> boolean equals(Comparable<A> a)
125 {
126 return true;
127 }
128 }
129
130 private class InputBraces {
131
132 }
133
134 private class InputModifier {
135
136 }
137 }