use value from method call on Enum as annotation parameter

Viewed 954

I have

enum Operations { 
 OPERATION_NAME("operation/path");    
    private final String path;

    Operations(String path) {
        this.path = path;
    }

    public String path() {
        return path;
    }
}

I would like to use value of path on annotations on my REST API methods

  @Path(Operations.OPERATION_NAME.path())
  void operation() {
  }

but java compiler complains

Attribute value must be constant

Is there a way to resolve that in java8?

I know I could have one enum with operation names and bunch of static String fields with paths (static Strings can be used as attribute in @Path annotation) but I do not like this approach.

1 Answers
Related