How can I insert an runtime environment variable in an annotation attribute value in Java?

Viewed 248

I have been trying to populate an annotation attribute value at runtime, but it is not being able to compile The error is

"The value for annotation attribute DynamoDBIndexHashKey.globalSecondaryIndexName must be a constant expression"

Here is the snippet

public static final String GLOBAL_SECONDARY_INDEX = "RENDITIONS" + System.getenv("REGION_CODE") + "-" +System.getenv("STAGE") + "-renditionStatus-Index";

@DynamoDBIndexHashKey(globalSecondaryIndexName  = GLOBAL_SECONDARY_INDEX, attributeName ="renditionStatus")

The value for GLOBAL_SECONDARY_INDEX for the attribute globalSecondaryIndexName is not able to compile as a constant despite of using the "+" operator. Am I missing something? Many Thanks in advance for trying to help

0 Answers
Related