Ticket #23727: 23727.patch
File 23727.patch, 951 bytes (added by , 6 months ago) |
---|
-
src/org/openstreetmap/josm/tools/Utils.java
635 635 */ 636 636 @SuppressWarnings("unchecked") 637 637 public static <T> List<T> toUnmodifiableList(Collection<T> collection) { 638 // Java 9: use List.of(...) 638 639 if (isEmpty(collection)) { 639 640 return Collections.emptyList(); 640 641 } else if (collection.size() == 1) { 641 642 return Collections.singletonList(collection.iterator().next()); 642 643 } else { 643 // List.copyOf would also work, but if the original collection is immutable, it just returns the original 644 // collection. 645 return (List<T>) List.of(collection.toArray()); 644 return (List<T>) Arrays.asList(collection.toArray()); 646 645 } 647 646 } 648 647