| 1 | package com.yubico.internal.util; | |
| 2 | ||
| 3 | import java.util.ArrayList; | |
| 4 | import java.util.Collections; | |
| 5 | import java.util.HashMap; | |
| 6 | import java.util.HashSet; | |
| 7 | import java.util.List; | |
| 8 | import java.util.Map; | |
| 9 | import java.util.Set; | |
| 10 | import java.util.SortedSet; | |
| 11 | import java.util.TreeSet; | |
| 12 | ||
| 13 | public class CollectionUtil { | |
| 14 | ||
| 15 | /** | |
| 16 | * Make an unmodifiable shallow copy of the argument. | |
| 17 | * | |
| 18 | * @return A shallow copy of <code>m</code> which cannot be modified | |
| 19 | */ | |
| 20 | public static <K, V> Map<K, V> immutableMap(Map<K, V> m) { | |
| 21 |
1
1. immutableMap : replaced return value with Collections.emptyMap for com/yubico/internal/util/CollectionUtil::immutableMap → KILLED |
return Collections.unmodifiableMap(new HashMap<>(m)); |
| 22 | } | |
| 23 | ||
| 24 | /** | |
| 25 | * Make an unmodifiable shallow copy of the argument. | |
| 26 | * | |
| 27 | * @return A shallow copy of <code>l</code> which cannot be modified | |
| 28 | */ | |
| 29 | public static <T> List<T> immutableList(List<T> l) { | |
| 30 |
1
1. immutableList : replaced return value with Collections.emptyList for com/yubico/internal/util/CollectionUtil::immutableList → KILLED |
return Collections.unmodifiableList(new ArrayList<>(l)); |
| 31 | } | |
| 32 | ||
| 33 | /** | |
| 34 | * Alias of <code>s == null ? Collections.emptyList() : CollectionUtil.immutableList(s)</code>. | |
| 35 | */ | |
| 36 | public static <T> List<T> immutableListOrEmpty(List<T> l) { | |
| 37 |
2
1. immutableListOrEmpty : negated conditional → NO_COVERAGE 2. immutableListOrEmpty : replaced return value with Collections.emptyList for com/yubico/internal/util/CollectionUtil::immutableListOrEmpty → NO_COVERAGE |
return l == null ? Collections.emptyList() : immutableList(l); |
| 38 | } | |
| 39 | ||
| 40 | /** | |
| 41 | * Make an unmodifiable shallow copy of the argument. | |
| 42 | * | |
| 43 | * @return A shallow copy of <code>s</code> which cannot be modified | |
| 44 | */ | |
| 45 | public static <T> Set<T> immutableSet(Set<T> s) { | |
| 46 |
1
1. immutableSet : replaced return value with Collections.emptySet for com/yubico/internal/util/CollectionUtil::immutableSet → KILLED |
return Collections.unmodifiableSet(new HashSet<>(s)); |
| 47 | } | |
| 48 | ||
| 49 | /** Alias of <code>s == null ? Collections.emptySet() : CollectionUtil.immutableSet(s)</code>. */ | |
| 50 | public static <T> Set<T> immutableSetOrEmpty(Set<T> s) { | |
| 51 |
2
1. immutableSetOrEmpty : replaced return value with Collections.emptySet for com/yubico/internal/util/CollectionUtil::immutableSetOrEmpty → NO_COVERAGE 2. immutableSetOrEmpty : negated conditional → NO_COVERAGE |
return s == null ? Collections.emptySet() : immutableSet(s); |
| 52 | } | |
| 53 | ||
| 54 | /** | |
| 55 | * Make an unmodifiable shallow copy of the argument. | |
| 56 | * | |
| 57 | * @return A shallow copy of <code>s</code> which cannot be modified | |
| 58 | */ | |
| 59 | public static <T> SortedSet<T> immutableSortedSet(Set<T> s) { | |
| 60 |
1
1. immutableSortedSet : replaced return value with null for com/yubico/internal/util/CollectionUtil::immutableSortedSet → KILLED |
return Collections.unmodifiableSortedSet(new TreeSet<>(s)); |
| 61 | } | |
| 62 | } | |
Mutations | ||
| 21 |
1.1 |
|
| 30 |
1.1 |
|
| 37 |
1.1 2.2 |
|
| 46 |
1.1 |
|
| 51 |
1.1 2.2 |
|
| 60 |
1.1 |