Search code examples
javadictionarysequencetalend

Sequence doesn't count upwards


I have following piece of code, which basically does append everything corect, but the Sequence doesn't count upwards. Any Idea whats wrong there?

globalMap.containsKey(row1.File_Name.toUpperCase()) ?
    (String)globalMap.get(row1.File_Name.toUpperCase()) :
    (globalMap.put(row1.File_Name.toUpperCase(), row1.File_Name.toUpperCase() + 
       "-ID-" + Numeric.sequence(row1.File_Name, 1, +1).toString()) == null ?
    (String)globalMap.get(row1.File_Name.toUpperCase()) :
    (String)globalMap.get(row1.File_Name.toUpperCase())

Thanks in advance for advice!


Solution

  • Ah, figured it out - had to switch the true and false conditions, as I wanted to count up the same ones.

    I guess my brain was too messed up yesterday - new day, refreshed brain, and done.

    globalMap.containsKey(row1.File_Name.toUpperCase()) ?
        (globalMap.put(row1.File_Name.toUpperCase(), row1.File_Name.toUpperCase() + 
           "-ID-" + Numeric.sequence(row1.File_Name, 1, +1).toString()) == null ?
                (String)globalMap.get(row1.File_Name.toUpperCase()) :
                (String)globalMap.get(row1.File_Name.toUpperCase()) 
        ):
        (String)globalMap.get(row1.File_Name.toUpperCase())