Skip to content

Instantly share code, notes, and snippets.

@ivanarrizabalaga
Created October 28, 2013 12:39
Show Gist options
  • Save ivanarrizabalaga/7196128 to your computer and use it in GitHub Desktop.
Save ivanarrizabalaga/7196128 to your computer and use it in GitHub Desktop.
Playing with enums in order to translate one value from one enum to the corresponding value in a different enum based on its ordinal.
enum CommunicationStateEnum {
DESIGN, APROBADA, EJECUTADA, EN_PROGRESO, FINALIZADA, CANCELADA
}
enum CampaignStateEnum {
DESIGN, APROBADA, EJECUTADA, EN_PROGRESO, FINALIZADA, CANCELADA
}
CommunicationStateEnum campaignState2ComunicationState(CampaignStateEnum campaignState){
if(!campaignState) return null
return CommunicationStateEnum.values()[campaignState.ordinal()]
}
CampaignStateEnum input
CommunicationStateEnum output=campaignState2ComunicationState(input)
println output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment