Android parse String into StringDef -
i have declared @stringdef
in code :
@stringdef({notificationaction.displayed, notificationaction.content_clicked, notificationaction.action_clicked, notificationaction.dismissed}) @retention(retentionpolicy.source) public @interface notificationaction { string displayed = "displayed"; string content_clicked = "contentclicked"; string action_clicked = "actionclicked"; string dismissed = "dismissed"; }
how parse new string notificationaction without individually comparing each of them?
in enum, can directly use valueof
function. couldn't find similar here.
it seems cannot else implementing it. did following.
public class job { @intdef(value = { status.stopped, status.started, status.new }) @retention(retentionpolicy.source) @interface jobstatus { } public static class status { public static final int stopped = 0; public static final int started = 1; public static final int new = 2; @jobstatus static int getstatus(int status) { return status; } @jobstatus static int fromname(string name) { switch (name) { case "stopped": return stopped; case "started": return started; case "new": return new; default: return new; } } } }
maybe can you.
Comments
Post a Comment