Is there a common or standard annotation in Java for methods that, while defined, have yet to be implemented?
Java中是否有一个通用或标准的注释用于定义尚未实现的方法?
So that, for instance, if I were using a pre-alpha version of a library that contained something like
因此,例如,如果我使用包含类似内容的库的pre-alpha版本
@NotImplementedYet
public void awesomeMethodThatTotallyDoesExactlyWhatYouNeed(){ /* TODO */ }
I'd get a compile-time warning when trying to call awesomeMethodThatTotallyDoesExactlyWhatYouNeed
?
在尝试调用awesomeMethodThatTotallyDoesExactlyWhatYouNeed时,我会收到编译时警告?
3 个解决方案
#1
14
You might want to use UnsupportedOperationException and detect calls to-yet-to-be-implemented methods when running your tests.
您可能希望在运行测试时使用UnsupportedOperationException并检测对尚未实现的方法的调用。
#2
2
You could create your own annotation. With the runtime retention policy you can then configure target builds to know to look for this annotation, if necessary.
您可以创建自己的注释。使用运行时保留策略,您可以配置目标构建,以便在必要时查找此批注。
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({
ElementType.ANNOTATION_TYPE,
ElementType.METHOD,
ElementType.CONSTRUCTOR,
ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface Unimplemented {
boolean value() default true;
}
#3
#1
14
You might want to use UnsupportedOperationException and detect calls to-yet-to-be-implemented methods when running your tests.
您可能希望在运行测试时使用UnsupportedOperationException并检测对尚未实现的方法的调用。
#2
2
You could create your own annotation. With the runtime retention policy you can then configure target builds to know to look for this annotation, if necessary.
您可以创建自己的注释。使用运行时保留策略,您可以配置目标构建,以便在必要时查找此批注。
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({
ElementType.ANNOTATION_TYPE,
ElementType.METHOD,
ElementType.CONSTRUCTOR,
ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface Unimplemented {
boolean value() default true;
}