My obsolete annotation

Can I create an annotation like @deprecated, I mean, with legacy code?

I would like to create an annotation that indicates that some messages have been deleted from the communication protocol, so I do not want to use an outdated annotation because I want 1) to give a better and more suggestive name for my annotation, like "message deleted" 2) specify parameters for my annotation, for example (protocol = 5) - removed from protocol 5.

But I want this strikethrough code for others to know that this message has been deleted simply by looking at the code.

+4
source share
5 answers

@ ( , ). . IDE - , "" - (, "" ). - , : .

+3

, , , . IDE @Deprecated .

:

@Documented
@Retention(RetentionPolicy.RUNTIME)
public @interface Deprecated {
}
+1

, :

 @Deprecated ,  @deprecated tag javadoc

!

java :

J2SE 5.0 , @Deprecated. , @deprecated Javadoc, , .

Java , , . , , . API .

Javadoc @deprecated , , API. , API API

+1

,

MessageRemoved:

public @interface MessageRemoved {
    Protocol protocol();
}

:

public enum Protocol {
    P01, P02, P03, P04, P05
}

:

@MessageRemoved(protocol = Protocol.P05)
public class OldMessage extends Message{
}

. @Deprecated .

0

+1 oleg.lukyrych , - .

( ), . .. PMD . PMD IDE , hudson/jenkins. () .

, , .

, .

0

All Articles