Skip to content

Commit 59c8da0

Browse files
arthurbeyer1601cbuschka
authored andcommitted
Added KeepTheCompilerHappy annotation
1 parent c868177 commit 59c8da0

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.github.codestickers;
2+
3+
import java.lang.annotation.*;
4+
5+
/**
6+
* Annotation to show that some logic
7+
* is just for the compiler to run without complaining
8+
*/
9+
10+
@Retention(RetentionPolicy.CLASS)
11+
@Target({ElementType.TYPE,
12+
ElementType.FIELD,
13+
ElementType.METHOD,
14+
ElementType.CONSTRUCTOR,
15+
ElementType.LOCAL_VARIABLE,
16+
ElementType.ANNOTATION_TYPE,
17+
ElementType.PACKAGE,
18+
ElementType.TYPE_PARAMETER,
19+
ElementType.TYPE_USE})
20+
@Documented
21+
public @interface KeepTheCompilerHappy {
22+
String value() default "";
23+
}
24+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.github.codestickers;
2+
3+
public class KeepTheCompilerHappyTest {
4+
5+
@KeepTheCompilerHappy("Needs to return something when testing")
6+
public static String usesIsTestVariableForWhateverReason(boolean isTest) {
7+
if (isTest) {
8+
return "test";
9+
} else {
10+
return "important data";
11+
}
12+
}
13+
}
14+
15+

0 commit comments

Comments
 (0)