1
2
3
4
5
6
7 package com.puppycrawl.tools.checkstyle.checks.design.hideutilityclassconstructor;
8
9
10
11
12
13 public abstract class InputHideUtilityClassConstructorDesignForExtension
14 {
15
16
17 public interface InterfaceOK
18 {
19 void implicitlyAbstract();
20 }
21
22 final class ClassOK
23 {
24 protected void finalThroughClassDef()
25 {
26 System.identityHashCode("no way to override");
27 }
28 }
29
30 protected void nonFinalButEmpty()
31 {
32 }
33
34 public void nonFinalButEmpty2()
35 {
36
37 }
38
39 private void aPrivateMethod()
40 {
41 System.identityHashCode("no way to override");
42 }
43
44 protected abstract void nonFinalButAbstract();
45
46
47
48 protected void doh()
49 {
50 System.identityHashCode("nonempty and overriding possible");
51 }
52
53 public final void aFinalMethod()
54 {
55 System.identityHashCode("no way to override");
56 }
57
58 public static void aStaticMethod()
59 {
60 System.identityHashCode("no way to override");
61 }
62
63
64
65
66 private class MyComparator implements java.util.Comparator
67 {
68 public int compare(Object o1, Object o2)
69 {
70
71 if (o1.hashCode() > o2.hashCode()) {
72 return -1;
73 }
74 else {
75 return 1;
76 }
77 }
78 }
79
80 public final class aFinalClass
81 {
82 public void someMethod()
83 {
84 System.identityHashCode("nonempty and overriding is possible");
85 }
86 }
87
88 public class nonFinalClass
89 {
90
91 private nonFinalClass(){}
92 public void someMethod()
93 {
94 System.identityHashCode("nonempty and overriding is possible");
95 }
96 }
97
98 public class anotherNonFinalClass
99 {
100
101 public anotherNonFinalClass(){}
102 public void someMethod()
103 {
104 System.identityHashCode("nonempty and overriding is possible");
105 }
106 }
107
108
109 public enum TEnum
110 {
111 FIRST,
112 SECOND;
113
114 public int value()
115 {
116 return 3;
117 }
118 }
119 }