Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
Scope |
|
| 1.0;1 |
1 | //////////////////////////////////////////////////////////////////////////////// | |
2 | // checkstyle: Checks Java source code for adherence to a set of rules. | |
3 | // Copyright (C) 2001-2014 Oliver Burn | |
4 | // | |
5 | // This library is free software; you can redistribute it and/or | |
6 | // modify it under the terms of the GNU Lesser General Public | |
7 | // License as published by the Free Software Foundation; either | |
8 | // version 2.1 of the License, or (at your option) any later version. | |
9 | // | |
10 | // This library is distributed in the hope that it will be useful, | |
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | // Lesser General Public License for more details. | |
14 | // | |
15 | // You should have received a copy of the GNU Lesser General Public | |
16 | // License along with this library; if not, write to the Free Software | |
17 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | //////////////////////////////////////////////////////////////////////////////// | |
19 | package com.puppycrawl.tools.checkstyle.api; | |
20 | ||
21 | /** | |
22 | * Represents a Java visibility scope. | |
23 | * | |
24 | * @author Lars Kühne | |
25 | * @author Travis Schneeberger | |
26 | */ | |
27 | 8 | public enum Scope |
28 | { | |
29 | /** nothing scope. */ | |
30 | 1 | NOTHING, |
31 | /** protected scope. */ | |
32 | 1 | PUBLIC, |
33 | /** protected scope. */ | |
34 | 1 | PROTECTED, |
35 | /** package or default scope. */ | |
36 | 1 | PACKAGE, |
37 | /** private scope. */ | |
38 | 1 | PRIVATE, |
39 | /** anonymous inner scope. */ | |
40 | 1 | ANONINNER; |
41 | ||
42 | @Override | |
43 | public String toString() | |
44 | { | |
45 | 1 | return getName(); |
46 | } | |
47 | ||
48 | /** | |
49 | * @return the name of this severity level. | |
50 | */ | |
51 | public String getName() | |
52 | { | |
53 | 23 | return name().toLowerCase(); |
54 | } | |
55 | ||
56 | /** | |
57 | * Checks if this scope is a subscope of another scope. | |
58 | * Example: PUBLIC is a subscope of PRIVATE. | |
59 | * | |
60 | * @param aScope a <code>Scope</code> value | |
61 | * @return if <code>this</code> is a subscope of <code>aScope</code>. | |
62 | */ | |
63 | public boolean isIn(Scope aScope) | |
64 | { | |
65 | 2443 | return (compareTo(aScope) <= 0); |
66 | } | |
67 | ||
68 | /** | |
69 | * Scope factory method. | |
70 | * | |
71 | * @param aScopeName scope name, such as "nothing", "public", etc. | |
72 | * @return the <code>Scope</code> associated with <code>aScopeName</code> | |
73 | */ | |
74 | public static Scope getInstance(String aScopeName) | |
75 | { | |
76 | 36 | return valueOf(Scope.class, aScopeName.trim().toUpperCase()); |
77 | } | |
78 | } |