private List < Tag > mergeS3TagSet ( List < Tag > initialTags , Tag changeTag ) { Map < String , String > mergedTags = initialTags . stream ( ) . collect ( Collectors . toMap ( Tag :: getKey , Tag :: getValue ) ) ; mergedTags . put ( changeTag . getKey ( ) , changeTag . getValue ( ) ) ; return mergedTags . entrySet ( ) . stream ( ) . map ( entry -> new Tag ( entry . getKey ( ) , entry . getValue ( ) ) ) . collect ( Collectors . toList ( ) ) ; }
Merges a new tag into an existing list of tags . It will be either appended to the list or overwrite the value of an existing tag with the same key .