Skip to content

Commit 003cafb

Browse files
committed
VisibleForTesting annotation added (#26)
1 parent a0605ed commit 003cafb

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

common/src/main/java/org/jetbrains/annotations/TestOnly.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import java.lang.annotation.*;
1919

2020
/**
21-
* A method/constructor annotated with TestOnly claims that it should be called from testing code only.
21+
* A member or type annotated with TestOnly claims that it should be used from testing code only.
2222
* <p>
2323
* Apart from documentation purposes this annotation is intended to be used by static analysis tools
2424
* to validate against element contract violations.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright 2000-2015 JetBrains s.r.o.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.jetbrains.annotations;
17+
18+
import java.lang.annotation.Documented;
19+
import java.lang.annotation.ElementType;
20+
import java.lang.annotation.Retention;
21+
import java.lang.annotation.RetentionPolicy;
22+
import java.lang.annotation.Target;
23+
24+
/**
25+
* A member or type annotated with VisibleForTesting claims that its visibility is higher than necessary,
26+
* only for testing purposes. In particular:
27+
* <ul>
28+
* <li>If public or protected member/type is annotated with VisibleForTesting,
29+
* it's assumed that package-private access is enough for production code.</li>
30+
* <li>If package-private member/type is annotated with VisibleForTesting,
31+
* it's assumed that private access is enough for production code.</li>
32+
* <li>It's illegal to annotate private member/type as VisibleForTesting.</li>
33+
* </ul>
34+
*
35+
* @since 20.0.0
36+
*/
37+
@Documented
38+
@Retention(RetentionPolicy.SOURCE)
39+
@Target({ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.TYPE})
40+
public @interface VisibleForTesting { }

0 commit comments

Comments
 (0)