Can annotation in Android receive two different data type or do the conversion internally? So that it can read both data type. For example a usual annotation:

@StringDef({CheckInReward.NEW, CheckInReward.USED})
@Retention(RetentionPolicy.SOURCE)
public @interface CheckInReward{
  String NEW = "NEW";
  String USED = "USED"; }

So let say if backend pass me this status in integer format (new = 1, used = 2). But I don't want to create a new annotation file, can I reuse this file but tweak something inside? like

@StringDef({CheckInReward.NEW, CheckInReward.USED})
@IntDef({CheckInReward.new, CheckInReward.used})
@Retention(RetentionPolicy.SOURCE)
public @interface CheckInReward{
  String NEW = "NEW";
  String USED = "USED";
  int new = 1;
  int used = 2; }

I don't know is there any similar question but as my searching doesn't show any result. I know this is not the second piece of code is not working. Just an example defining my question.

0 Answers