Should I compose a class of constants for my annotations?

What's better?

  • @SuppressWarnings("unchecked")
  • @SuppressWarnings(AnnotationConstants.UNCHECKED)

Where AnnotationConstantsis a typical class of constants ...

public final class AnnotationConstants {
    private AnnotationConstants() { }

    public static final String UNCHECKED = "unchecked";

    ...
}

I know that there are many common arguments for classes of constants and against them - and that’s exactly what I'm not interested in . I want to know if the class of constants is really for annotations, a good idea or a bad idea.

+3
source share
4 answers

In this particular example, I would stick with literals. In the end, you are trying to suppress warnings - if you use the wrong literal, the warning will not be suppressed, which will draw your attention to the problem.

+6
source

, .

Spring - @Scope (Scopes.SESSION) @Scope (Scopes.REQUEST), , , , .

, , , .

+3

Holsam SuppressWarnings -

, usng, , ,

+2

@SuppressWarning , . , , . Eclipse .

0

Source: https://habr.com/ru/post/1704518/


All Articles