| 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 | /** Alias of <code>s == null ? Collections.emptyMap() : CollectionUtil.immutableMap(s)</code>. */ | |
| 25 | public static <K, V> Map<K, V> immutableMapOrEmpty(Map<K, V> s) { | |
| 26 |
2
1. immutableMapOrEmpty : negated conditional → NO_COVERAGE 2. immutableMapOrEmpty : replaced return value with Collections.emptyMap for com/yubico/internal/util/CollectionUtil::immutableMapOrEmpty → NO_COVERAGE |
return s == null ? Collections.emptyMap() : immutableMap(s); |
| 27 | } | |
| 28 | ||
| 29 | /** | |
| 30 | * Make an unmodifiable shallow copy of the argument. | |
| 31 | * | |
| 32 | * @return A shallow copy of <code>l</code> which cannot be modified | |
| 33 | */ | |
| 34 | public static <T> List<T> immutableList(List<T> l) { | |
| 35 |
1
1. immutableList : replaced return value with Collections.emptyList for com/yubico/internal/util/CollectionUtil::immutableList → KILLED |
return Collections.unmodifiableList(new ArrayList<>(l)); |
| 36 | } | |
| 37 | ||
| 38 | /** | |
| 39 | * Alias of <code>s == null ? Collections.emptyList() : CollectionUtil.immutableList(s)</code>. | |
| 40 | */ | |
| 41 | public static <T> List<T> immutableListOrEmpty(List<T> l) { | |
| 42 |
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); |
| 43 | } | |
| 44 | ||
| 45 | /** | |
| 46 | * Make an unmodifiable shallow copy of the argument. | |
| 47 | * | |
| 48 | * @return A shallow copy of <code>s</code> which cannot be modified | |
| 49 | */ | |
| 50 | public static <T> Set<T> immutableSet(Set<T> s) { | |
| 51 |
1
1. immutableSet : replaced return value with Collections.emptySet for com/yubico/internal/util/CollectionUtil::immutableSet → KILLED |
return Collections.unmodifiableSet(new HashSet<>(s)); |
| 52 | } | |
| 53 | ||
| 54 | /** Alias of <code>s == null ? Collections.emptySet() : CollectionUtil.immutableSet(s)</code>. */ | |
| 55 | public static <T> Set<T> immutableSetOrEmpty(Set<T> s) { | |
| 56 |
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); |
| 57 | } | |
| 58 | ||
| 59 | /** | |
| 60 | * Make an unmodifiable shallow copy of the argument. | |
| 61 | * | |
| 62 | * @return A shallow copy of <code>s</code> which cannot be modified | |
| 63 | */ | |
| 64 | public static <T> SortedSet<T> immutableSortedSet(Set<T> s) { | |
| 65 |
1
1. immutableSortedSet : replaced return value with null for com/yubico/internal/util/CollectionUtil::immutableSortedSet → KILLED |
return Collections.unmodifiableSortedSet(new TreeSet<>(s)); |
| 66 | } | |
| 67 | } | |
Mutations | ||
| 21 |
1.1 |
|
| 26 |
1.1 2.2 |
|
| 35 |
1.1 |
|
| 42 |
1.1 2.2 |
|
| 51 |
1.1 |
|
| 56 |
1.1 2.2 |
|
| 65 |
1.1 |