obtaining Groovy map value by key

Viewed 5670

I'm a complete groovy noob, I have this simple map:

def BranchToPort = [
    [branch: 'master'   , port: 15565],
    [branch: 'Release'  , port: 15566],
    [branch: 'Feature'  , port: 15567],
    [branch: 'Prototype', port: 15568],
    [branch: 'HotFix'   , port: 15569]
]

and given a branch name (the key) I want to obtain the port number, preferably in a single line of code. Bizarrely there are a ton of examples across the internet for obtaining the key based on its corresponding value, but not the other way around.

2 Answers
Related