Ignore:
Timestamp:
2020-05-17T12:08:17+02:00 (4 years ago)
Author:
simon04
Message:

see #19251 - Java 8: use Stream

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/spi/preferences/ListListSetting.java

    r12882 r16436  
    44import java.util.ArrayList;
    55import java.util.Collection;
    6 import java.util.Collections;
    76import java.util.List;
     7import java.util.stream.Collectors;
     8
     9import org.openstreetmap.josm.tools.StreamUtils;
     10import org.openstreetmap.josm.tools.Utils;
    811
    912/**
     
    2932    public static ListListSetting create(Collection<Collection<String>> value) {
    3033        if (value != null) {
    31             List<List<String>> valueList = new ArrayList<>(value.size());
    32             for (Collection<String> lst : value) {
    33                 valueList.add(new ArrayList<>(lst));
    34             }
     34            List<List<String>> valueList = value.stream()
     35                    .map(ArrayList::new)
     36                    .collect(Collectors.toList());
    3537            return new ListListSetting(valueList);
    3638        }
     
    4345            return new ListListSetting(null);
    4446
    45         List<List<String>> copy = new ArrayList<>(value.size());
    46         for (Collection<String> lst : value) {
    47             List<String> lstCopy = new ArrayList<>(lst);
    48             copy.add(Collections.unmodifiableList(lstCopy));
    49         }
    50         return new ListListSetting(Collections.unmodifiableList(copy));
     47        List<List<String>> copy = value.stream()
     48                .map(Utils::toUnmodifiableList)
     49                .collect(StreamUtils.toUnmodifiableList());
     50        return new ListListSetting(copy);
    5151    }
    5252
Note: See TracChangeset for help on using the changeset viewer.