0

In my code, I have several uses of the same annotation which has three property values, one of which always has the same value.

@ApiModelProperty(value = "some value", 
        allowableValues = "available,pending,sold", dataType="myclass.Payload")

dataType="myclass.Payload" is always the same value.

Is there anyway I can get a bit of code reuse here?

More Than Five
  • 9,959
  • 21
  • 77
  • 127
  • Barring any framework specific features (e.g. configuration files), you could try storing the value in some `public static final` field somewhere. Since the value is a string literal it would be a constant and thus usable in annotations. – Slaw Jun 25 '19 at 00:21
  • Please have a look at an example here - (https://stackoverflow.com/questions/2065937/how-to-supply-value-to-an-annotation-from-a-constant-java) – Anshul Singhal Jun 25 '19 at 02:46

0 Answers0