Is it possible to use the @Deprecated
annotation on enum constants?
If you check the javadoc, you will see the declaration:
@Target(value={CONSTRUCTOR,FIELD,LOCAL_VARIABLE,METHOD,PACKAGE,PARAMETER,TYPE})
which includes FIELD
. If you click on FIELD
you get to its javadoc which states:
Field declaration (includes enum constants)
So the answer is: yes it should work fine.
Yes, put a @Deprecated
annotation on them (uppercase). For example:
public enum Status {
OK,
ERROR,
@Deprecated
PROBLEM
}
@Deprecated is an annotation that is read by the compiler, used to mark a method as deprecated to the compiler and will generate a deprecation compile-time warning if the method is used.
@deprecated is a javadoc tag used to provide documentation about the deprecation. You can use it to explain why the method was deprecated and to suggest an alternative. It only makes sense to use this tag in conjunction to the @Deprecated annotation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With