add a postfix to a string v.getName() for a collection of strings in groovy for Jira scriptrunner

I would like to add a postfix called "-Inbox" to each of the elements of a collection of strings. Here is my current approach:

def matchedVersions = issue.getFixVersions().intersect(
def mynewVersions = new ArrayList <Version> ()

 for( Version v: matchedVersions){
           Version mynewVersion= ComponentAccessor.versionManager.createVersion(v.getName()+"-Inbox", startDate, releaseDate, description,, scheduleAfterVersion, released)

Is there a simpler approach that I could use to avoid the loop, the action I am doing is repetitive and takes time and I would like to find a new approach. I just need to create a new varaible called mynewVersions which is identical to matchedVersions with the only difference being that the name of each version has the postfix "-Inbox" appended.


  • Some plain groovy with List-operations and right-currying of a createVersion() method:

    def versionCreator = ComponentAccessor.versionManager.&createVersion.rcurry( startDate, releaseDate, description,, scheduleAfterVersion, released )
    def mynewVersions = issue.fixVersions.intersect( newIssueproject.versions, Version.NAME_COMPARATOR ).collect{ versionCreator + '-Inbox' }