Java 8 stream map on entry set

前端 未结 5 1727
失恋的感觉
失恋的感觉 2020-12-29 19:22

I\'m trying to perform a map operation on each entry in a Map object.

I need to take a prefix off the key and convert the value from one type to another

5条回答
  •  天命终不由人
    2020-12-29 20:07

    Here is a shorter solution by AbacusUtil

    Stream.of(input).toMap(e -> e.getKey().substring(subLength), 
                           e -> AttributeType.GetByName(e.getValue()));
    

提交回复
热议问题