01: ////////////////////////////////////////////////////////////////////////////////
02: // Test case file for checkstyle.
03: // Created: 2001
04: ////////////////////////////////////////////////////////////////////////////////
05: package com.puppycrawl.tools.checkstyle;
06:
07: /**
08: * Test case for the "design for inheritance" check.
09: * @author Lars Kühne
10: **/
11: public abstract class InputDesignForExtension {
12: // some methods that are OK
13:
14: public interface InterfaceOK {
15: void implicitlyAbstract();
16: }
17:
18: final class ClassOK {
19: protected void finalThroughClassDef() {
20: System.out.println("no way to override");
21: }
22: }
23:
24: protected void nonFinalButEmpty() {
25: }
26:
27: public void nonFinalButEmpty2() {
28: // comments don't count as content...
29: }
30:
31: private void aPrivateMethod() {
32: System.out.println("no way to override");
33: }
34:
35: protected abstract void nonFinalButAbstract();
36:
37: // this one is bad: neither abtract, final, or empty
38:
39: protected void doh() {
40: System.out.println("nonempty and overriding possible");
41: }
42:
43: // has a potentially complex implementation in native code.
44: // We can't check that, so to be safe DesignForExtension requires
45: // native methods to also be final
46: public native void aNativeMethod();
47:
48: // tries to trigger bug #884035
49: // MyComparator is a private class, so there cannot be subclasses
50: // and it should not be neccessary to declare compare() as final
51: private class MyComparator implements java.util.Comparator {
52: public int compare(Object o1, Object o2) {
53: // some complex stuff that would normally trigger an error report
54: if (o1.hashCode() > o2.hashCode()) {
55: return -1;
56: } else {
57: return 1;
58: }
59: }
60: }
61: }
62:
63: // enums should be skipped
64: enum TEnum {
65: FIRST, SECOND;
66:
67: public int value() {
68: return 3;
69: }
70: }
|