This is an automated email from the ASF dual-hosted git repository.
jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git
The following commit(s) were added to refs/heads/master by this push:
new 982df1f355 SonarQube bug fixes
982df1f355 is described below
commit 982df1f35549b1da82aa11c0d17783966ece7331
Author: James Bognar <[email protected]>
AuthorDate: Wed Feb 18 11:38:04 2026 -0500
SonarQube bug fixes
---
.../juneau/commons/utils/CollectionUtils.java | 58 +++++++--------
.../apache/juneau/commons/utils/StringUtils.java | 2 +-
.../org/apache/juneau/collections/JsonMap.java | 2 +-
.../apache/juneau/objecttools/ObjectSorter.java | 2 +-
.../apache/juneau/objecttools/ObjectViewer.java | 2 +-
.../org/apache/juneau/xml/XmlParserSession.java | 2 +-
.../main/java/org/apache/juneau/xml/XmlUtils.java | 2 +-
.../juneau/examples/core/pojo/PojoComplex.java | 6 +-
.../juneau/commons/utils/CollectionUtils_Test.java | 82 +++++++++++-----------
9 files changed, 79 insertions(+), 79 deletions(-)
diff --git
a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/utils/CollectionUtils.java
b/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/utils/CollectionUtils.java
index 8915a8260a..a824bb120c 100644
---
a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/utils/CollectionUtils.java
+++
b/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/utils/CollectionUtils.java
@@ -600,7 +600,7 @@ public class CollectionUtils {
* @param value The list to copy.
* @return A new modifiable list.
*/
- public static <E> ArrayList<E> copyOf(List<E> value) {
+ public static <E> List<E> copyOf(List<E> value) {
return value == null ? null : new ArrayList<>(value);
}
@@ -1006,7 +1006,7 @@ public class CollectionUtils {
* @see #list(Object...)
*/
@SafeVarargs
- public static <T> ArrayList<T> al(T...values) {
+ public static <T> List<T> al(T...values) {
return new ArrayList<>(l(values));
}
@@ -1026,7 +1026,7 @@ public class CollectionUtils {
* @return A new modifiable LinkedList containing the specified values.
*/
@SafeVarargs
- public static <T> LinkedList<T> ll(T...values) {
+ public static <T> List<T> ll(T...values) {
return new LinkedList<>(l(values));
}
@@ -1046,7 +1046,7 @@ public class CollectionUtils {
* @return A new modifiable HashSet containing the specified values.
*/
@SafeVarargs
- public static <T> HashSet<T> hs(T...values) {
+ public static <T> Set<T> hs(T...values) {
return new HashSet<>(Arrays.asList(values));
}
@@ -1067,7 +1067,7 @@ public class CollectionUtils {
* @return A new modifiable TreeSet containing the specified values.
*/
@SafeVarargs
- public static <T extends Comparable<T>> TreeSet<T> ts(T...values) {
+ public static <T extends Comparable<T>> SortedSet<T> ts(T...values) {
return new TreeSet<>(Arrays.asList(values));
}
@@ -1152,7 +1152,7 @@ public class CollectionUtils {
* @param size The initial size of the list.
* @return A new modifiable list.
*/
- public static <E> ArrayList<E> listOfSize(int size) {
+ public static <E> List<E> listOfSize(int size) {
return new ArrayList<>(size);
}
@@ -1440,7 +1440,7 @@ public class CollectionUtils {
* @param <V> The value type.
* @return A new modifiable map.
*/
- public static <K,V> LinkedHashMap<K,V> map() {
+ public static <K,V> Map<K,V> map() {
return new LinkedHashMap<>();
}
@@ -1457,7 +1457,7 @@ public class CollectionUtils {
* @param v1 Value 1.
* @return A new modifiable map.
*/
- public static <K,V> LinkedHashMap<K,V> map(K k1, V v1) {
+ public static <K,V> Map<K,V> map(K k1, V v1) {
var m = new LinkedHashMap<K,V>();
m.put(k1, v1);
return m;
@@ -1474,7 +1474,7 @@ public class CollectionUtils {
* @param v2 Value 2.
* @return A new modifiable map.
*/
- public static <K,V> LinkedHashMap<K,V> map(K k1, V v1, K k2, V v2) {
+ public static <K,V> Map<K,V> map(K k1, V v1, K k2, V v2) {
var m = new LinkedHashMap<K,V>();
m.put(k1, v1);
m.put(k2, v2);
@@ -1494,7 +1494,7 @@ public class CollectionUtils {
* @param v3 Value 3.
* @return A new modifiable map.
*/
- public static <K,V> LinkedHashMap<K,V> map(K k1, V v1, K k2, V v2, K
k3, V v3) {
+ public static <K,V> Map<K,V> map(K k1, V v1, K k2, V v2, K k3, V v3) {
var m = new LinkedHashMap<K,V>();
m.put(k1, v1);
m.put(k2, v2);
@@ -1520,7 +1520,7 @@ public class CollectionUtils {
@SuppressWarnings({
"java:S107" // Many parameters acceptable for convenience method
})
- public static <K,V> LinkedHashMap<K,V> map(K k1, V v1, K k2, V v2, K
k3, V v3, K k4, V v4) {
+ public static <K,V> Map<K,V> map(K k1, V v1, K k2, V v2, K k3, V v3, K
k4, V v4) {
var m = new LinkedHashMap<K,V>();
m.put(k1, v1);
m.put(k2, v2);
@@ -1549,7 +1549,7 @@ public class CollectionUtils {
@SuppressWarnings({
"java:S107" // Many parameters acceptable for convenience method
})
- public static <K,V> LinkedHashMap<K,V> map(K k1, V v1, K k2, V v2, K
k3, V v3, K k4, V v4, K k5, V v5) {
+ public static <K,V> Map<K,V> map(K k1, V v1, K k2, V v2, K k3, V v3, K
k4, V v4, K k5, V v5) {
var m = new LinkedHashMap<K,V>();
m.put(k1, v1);
m.put(k2, v2);
@@ -1581,7 +1581,7 @@ public class CollectionUtils {
@SuppressWarnings({
"java:S107" // Many parameters acceptable for convenience method
})
- public static <K,V> LinkedHashMap<K,V> map(K k1, V v1, K k2, V v2, K
k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6) {
+ public static <K,V> Map<K,V> map(K k1, V v1, K k2, V v2, K k3, V v3, K
k4, V v4, K k5, V v5, K k6, V v6) {
var m = new LinkedHashMap<K,V>();
m.put(k1, v1);
m.put(k2, v2);
@@ -1616,7 +1616,7 @@ public class CollectionUtils {
@SuppressWarnings({
"java:S107" // Many parameters acceptable for convenience method
})
- public static <K,V> LinkedHashMap<K,V> map(K k1, V v1, K k2, V v2, K
k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7) {
+ public static <K,V> Map<K,V> map(K k1, V v1, K k2, V v2, K k3, V v3, K
k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7) {
var m = new LinkedHashMap<K,V>();
m.put(k1, v1);
m.put(k2, v2);
@@ -1654,7 +1654,7 @@ public class CollectionUtils {
@SuppressWarnings({
"java:S107" // Many parameters acceptable for convenience method
})
- public static <K,V> LinkedHashMap<K,V> map(K k1, V v1, K k2, V v2, K
k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8) {
+ public static <K,V> Map<K,V> map(K k1, V v1, K k2, V v2, K k3, V v3, K
k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8) {
var m = new LinkedHashMap<K,V>();
m.put(k1, v1);
m.put(k2, v2);
@@ -1695,7 +1695,7 @@ public class CollectionUtils {
@SuppressWarnings({
"java:S107" // Many parameters acceptable for convenience method
})
- public static <K,V> LinkedHashMap<K,V> map(K k1, V v1, K k2, V v2, K
k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8, K k9, V
v9) {
+ public static <K,V> Map<K,V> map(K k1, V v1, K k2, V v2, K k3, V v3, K
k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8, K k9, V v9) {
var m = new LinkedHashMap<K,V>();
m.put(k1, v1);
m.put(k2, v2);
@@ -1739,7 +1739,7 @@ public class CollectionUtils {
@SuppressWarnings({
"java:S107" // Many parameters acceptable for convenience method
})
- public static <K,V> LinkedHashMap<K,V> map(K k1, V v1, K k2, V v2, K
k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8, K k9, V
v9, K k10, V v10) {
+ public static <K,V> Map<K,V> map(K k1, V v1, K k2, V v2, K k3, V v3, K
k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8, K k9, V v9, K k10, V
v10) {
var m = new LinkedHashMap<K,V>();
m.put(k1, v1);
m.put(k2, v2);
@@ -1907,7 +1907,7 @@ public class CollectionUtils {
* @param valueType The value type.
* @return A new modifiable map.
*/
- public static <K,V> LinkedHashMap<K,V> mapOf(Class<K> keyType, Class<V>
valueType) {
+ public static <K,V> Map<K,V> mapOf(Class<K> keyType, Class<V>
valueType) {
return map();
}
@@ -2013,7 +2013,7 @@ public class CollectionUtils {
* @return A modifiable LinkedHashSet containing the specified values.
*/
@SafeVarargs
- public static <T> LinkedHashSet<T> set(T...values) {
+ public static <T> Set<T> set(T...values) {
assertArgNotNull(ARG_values, values);
return new LinkedHashSet<>(Arrays.asList(values));
}
@@ -2057,7 +2057,7 @@ public class CollectionUtils {
* @return A new modifiable set.
*/
@SafeVarargs
- public static <E> LinkedHashSet<E> setOf(Class<E> elementType,
E...values) {
+ public static <E> Set<E> setOf(Class<E> elementType, E...values) {
return set(values);
}
@@ -2090,8 +2090,8 @@ public class CollectionUtils {
* @param value The values to initialize the list with.
* @return A new modifiable list.
*/
- public static <E> ArrayList<E> sortedList(Comparator<E> comparator,
Collection<E> value) {
- ArrayList<E> l = toList(value);
+ public static <E> List<E> sortedList(Comparator<E> comparator,
Collection<E> value) {
+ List<E> l = toList(value);
Collections.sort(l, comparator);
return l;
}
@@ -2132,7 +2132,7 @@ public class CollectionUtils {
* @param <V> The value type.
* @return A new modifiable set.
*/
- public static <K,V> TreeMap<K,V> sortedMap() {
+ public static <K,V> SortedMap<K,V> sortedMap() {
return new TreeMap<>();
}
@@ -2149,7 +2149,7 @@ public class CollectionUtils {
* @return A new modifiable set.
*/
@SafeVarargs
- public static <E> TreeSet<E> sortedSet(E...values) {
+ public static <E> SortedSet<E> sortedSet(E...values) {
assertArgNotNull(ARG_values, values);
var l = new TreeSet<E>();
for (var v : values)
@@ -2253,7 +2253,7 @@ public class CollectionUtils {
* @param value The collection to copy from.
* @return A new modifiable list.
*/
- public static <E> ArrayList<E> toList(Collection<E> value) {
+ public static <E> List<E> toList(Collection<E> value) {
return toList(value, false);
}
@@ -2268,7 +2268,7 @@ public class CollectionUtils {
@SuppressWarnings({
"java:S1168" // Intentional null when nullIfEmpty and (null
or empty).
})
- public static <E> ArrayList<E> toList(Collection<E> value, boolean
nullIfEmpty) {
+ public static <E> List<E> toList(Collection<E> value, boolean
nullIfEmpty) {
if (value == null)
return nullIfEmpty ? null : new ArrayList<>();
if (nullIfEmpty && value.isEmpty())
@@ -2458,7 +2458,7 @@ public class CollectionUtils {
* @param value The value to copy from.
* @return A new {@link TreeSet}, or an empty {@link TreeSet} if the
input was <jk>null</jk>.
*/
- public static <E> TreeSet<E> toSortedSet(Collection<E> value) {
+ public static <E> SortedSet<E> toSortedSet(Collection<E> value) {
if (value == null)
return new TreeSet<>();
var l = new TreeSet<E>();
@@ -2477,7 +2477,7 @@ public class CollectionUtils {
@SuppressWarnings({
"java:S1168" // Intentional null when nullIfEmpty and empty.
})
- public static <E> TreeSet<E> toSortedSet(Collection<E> value, boolean
nullIfEmpty) {
+ public static <E> SortedSet<E> toSortedSet(Collection<E> value, boolean
nullIfEmpty) {
if (value == null)
return new TreeSet<>();
if (nullIfEmpty && value.isEmpty())
@@ -2494,7 +2494,7 @@ public class CollectionUtils {
* @param copyFrom The set to copy from.
* @return A new {@link TreeSet}, or an empty {@link TreeSet} if the
input was <jk>null</jk>.
*/
- public static <T> TreeSet<T> toSortedSet(Set<T> copyFrom) {
+ public static <T> SortedSet<T> toSortedSet(Set<T> copyFrom) {
return copyFrom == null ? new TreeSet<>() : new
TreeSet<>(copyFrom);
}
diff --git
a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/utils/StringUtils.java
b/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/utils/StringUtils.java
index 68f5a838e9..e5e50cc7ff 100644
---
a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/utils/StringUtils.java
+++
b/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/utils/StringUtils.java
@@ -552,7 +552,7 @@ public class StringUtils {
* @param s The comma-delimited string.
* @return A new {@link LinkedHashSet}. Never <jk>null</jk>.
*/
- public static LinkedHashSet<String> cdlToSet(String s) {
+ public static Set<String> cdlToSet(String s) {
return
split(s).stream().collect(Collectors.toCollection(LinkedHashSet::new));
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/collections/JsonMap.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/collections/JsonMap.java
index 0dfc415c66..2aa7f91a86 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/collections/JsonMap.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/collections/JsonMap.java
@@ -1526,7 +1526,7 @@ public class JsonMap extends LinkedHashMap<String,Object>
{
public Set<String> keySet() {
if (inner == null)
return super.keySet();
- LinkedHashSet<String> s = set();
+ Set<String> s = set();
s.addAll(inner.keySet());
s.addAll(super.keySet());
return s;
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectSorter.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectSorter.java
index 444e416d16..bce6b58949 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectSorter.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectSorter.java
@@ -128,7 +128,7 @@ public class ObjectSorter implements ObjectTool<SortArgs> {
if (! type.isCollectionOrArray())
return input;
- ArrayList<SortEntry> l;
+ List<SortEntry> l;
if (type.isArray()) {
var size = Array.getLength(input);
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectViewer.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectViewer.java
index 61e3faf710..decc09dafd 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectViewer.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectViewer.java
@@ -92,7 +92,7 @@ public class ObjectViewer implements ObjectTool<ViewArgs> {
if (type.isBean())
return new DelegateBeanMap(input,
session).filterKeys(view);
- ArrayList<Object> l = null;
+ List<Object> l = null;
if (type.isArray()) {
var size = Array.getLength(input);
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlParserSession.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlParserSession.java
index 4b7ebce8e2..24052e7a01 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlParserSession.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlParserSession.java
@@ -408,7 +408,7 @@ public class XmlParserSession extends ReaderParserSession {
var cpcm = (cp == null ? object() : cp.getClassMeta());
StringBuilder sb = null;
var breg = cp == null ? null : cp.getBeanRegistry();
- LinkedList<Object> l = null;
+ List<Object> l = null;
int depth = 0;
do {
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlUtils.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlUtils.java
index 4e59848f4a..c5850887dc 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlUtils.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlUtils.java
@@ -76,7 +76,7 @@ public class XmlUtils {
* @param value The list of text nodes to collapse.
* @return The same list.
*/
- public static LinkedList<Object> collapseTextNodes(LinkedList<Object>
value) {
+ public static List<Object> collapseTextNodes(List<Object> value) {
StringBuilder prev = null;
for (ListIterator<Object> i = value.listIterator();
i.hasNext();) {
diff --git
a/juneau-examples/juneau-examples-core/src/main/java/org/apache/juneau/examples/core/pojo/PojoComplex.java
b/juneau-examples/juneau-examples-core/src/main/java/org/apache/juneau/examples/core/pojo/PojoComplex.java
index 7b2ca7f607..694b4a472c 100644
---
a/juneau-examples/juneau-examples-core/src/main/java/org/apache/juneau/examples/core/pojo/PojoComplex.java
+++
b/juneau-examples/juneau-examples-core/src/main/java/org/apache/juneau/examples/core/pojo/PojoComplex.java
@@ -28,7 +28,7 @@ public class PojoComplex {
private final String id;
private final Pojo innerPojo;
- private final HashMap<String,List<Pojo>> values;
+ private final Map<String,List<Pojo>> values;
/**
* Constructor.
@@ -38,7 +38,7 @@ public class PojoComplex {
* @param values The <bc>values</bc> property value.
*/
@Beanc
- public PojoComplex(@Name("id") String id, @Name("innerPojo") Pojo
innerPojo, @Name("values") HashMap<String,List<Pojo>> values) {
+ public PojoComplex(@Name("id") String id, @Name("innerPojo") Pojo
innerPojo, @Name("values") Map<String,List<Pojo>> values) {
this.id = id;
this.innerPojo = innerPojo;
this.values = values;
@@ -63,5 +63,5 @@ public class PojoComplex {
*
* @return The value of the <property>values</property> property on
this bean, or <jk>null</jk> if it is not set.
*/
- public HashMap<String,List<Pojo>> getValues() { return values; }
+ public Map<String,List<Pojo>> getValues() { return values; }
}
\ No newline at end of file
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/commons/utils/CollectionUtils_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/commons/utils/CollectionUtils_Test.java
index c58f67c3d3..b3e1234657 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/commons/utils/CollectionUtils_Test.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/commons/utils/CollectionUtils_Test.java
@@ -391,7 +391,7 @@ class CollectionUtils_Test extends TestBase {
@Test
void a020_copyOf_list() {
List<String> list = list("a", "b", "c");
- ArrayList<String> result = copyOf(list);
+ List<String> result = copyOf(list);
assertNotNull(result);
assertEquals(3, result.size());
assertEquals("a", result.get(0));
@@ -772,7 +772,7 @@ class CollectionUtils_Test extends TestBase {
//====================================================================================================
@Test
void a049_listOfSize() {
- ArrayList<String> result = listOfSize(5);
+ List<String> result = listOfSize(5);
assertNotNull(result);
assertEquals(0, result.size());
result.add("a");
@@ -876,61 +876,61 @@ class CollectionUtils_Test extends TestBase {
@Test
void a052_map() {
// Empty
- LinkedHashMap<String, Integer> empty = map();
+ Map<String, Integer> empty = map();
assertNotNull(empty);
assertTrue(empty.isEmpty());
empty.put("x", 1); // Modifiable
assertEquals(1, empty.size());
// 1 pair
- LinkedHashMap<String, Integer> m1 = map("a", 1);
+ Map<String, Integer> m1 = map("a", 1);
assertEquals(1, m1.size());
assertEquals(1, m1.get("a"));
// 2 pairs
- LinkedHashMap<String, Integer> m2 = map("a", 1, "b", 2);
+ Map<String, Integer> m2 = map("a", 1, "b", 2);
assertEquals(2, m2.size());
// 3 pairs
- LinkedHashMap<String, Integer> m3 = map("a", 1, "b", 2, "c", 3);
+ Map<String, Integer> m3 = map("a", 1, "b", 2, "c", 3);
assertEquals(3, m3.size());
// 4 pairs
- LinkedHashMap<String, Integer> m4 = map("a", 1, "b", 2, "c", 3,
"d", 4);
+ Map<String, Integer> m4 = map("a", 1, "b", 2, "c", 3, "d", 4);
assertEquals(4, m4.size());
var keys = new ArrayList<>(m4.keySet());
assertEquals(l("a", "b", "c", "d"), keys);
// 5 pairs
- LinkedHashMap<String, Integer> m5 = map("a", 1, "b", 2, "c", 3,
"d", 4, "e", 5);
+ Map<String, Integer> m5 = map("a", 1, "b", 2, "c", 3, "d", 4,
"e", 5);
assertEquals(5, m5.size());
// 6 pairs
- LinkedHashMap<String, Integer> m6 = map("a", 1, "b", 2, "c", 3,
"d", 4, "e", 5, "f", 6);
+ Map<String, Integer> m6 = map("a", 1, "b", 2, "c", 3, "d", 4,
"e", 5, "f", 6);
assertEquals(6, m6.size());
// 7 pairs - test lines 1400-1408
- LinkedHashMap<String, Integer> m7 = map("a", 1, "b", 2, "c", 3,
"d", 4, "e", 5, "f", 6, "g", 7);
+ Map<String, Integer> m7 = map("a", 1, "b", 2, "c", 3, "d", 4,
"e", 5, "f", 6, "g", 7);
assertEquals(7, m7.size());
assertEquals(7, m7.get("g"));
// 8 pairs - test lines 1435-1444
- LinkedHashMap<String, Integer> m8 = map("a", 1, "b", 2, "c", 3,
"d", 4, "e", 5, "f", 6, "g", 7, "h", 8);
+ Map<String, Integer> m8 = map("a", 1, "b", 2, "c", 3, "d", 4,
"e", 5, "f", 6, "g", 7, "h", 8);
assertEquals(8, m8.size());
assertEquals(8, m8.get("h"));
// 9 pairs - test lines 1473-1483
- LinkedHashMap<String, Integer> m9 = map("a", 1, "b", 2, "c", 3,
"d", 4, "e", 5, "f", 6, "g", 7, "h", 8, "i", 9);
+ Map<String, Integer> m9 = map("a", 1, "b", 2, "c", 3, "d", 4,
"e", 5, "f", 6, "g", 7, "h", 8, "i", 9);
assertEquals(9, m9.size());
assertEquals(9, m9.get("i"));
// 10 pairs
- LinkedHashMap<String, Integer> m10 = map("a", 1, "b", 2, "c",
3, "d", 4, "e", 5, "f", 6, "g", 7, "h", 8, "i", 9, "j", 10);
+ Map<String, Integer> m10 = map("a", 1, "b", 2, "c", 3, "d", 4,
"e", 5, "f", 6, "g", 7, "h", 8, "i", 9, "j", 10);
assertEquals(10, m10.size());
assertEquals(l("a", "b", "c", "d", "e", "f", "g", "h", "i",
"j"), new ArrayList<>(m10.keySet()));
// Null values
- LinkedHashMap<String, String> nullVals = map("a", "val1", "b",
null, "c", "val3", "d", null);
+ Map<String, String> nullVals = map("a", "val1", "b", null, "c",
"val3", "d", null);
assertEquals(4, nullVals.size());
assertNull(nullVals.get("b"));
}
@@ -983,7 +983,7 @@ class CollectionUtils_Test extends TestBase {
//====================================================================================================
@Test
void a057_mapOf() {
- LinkedHashMap<String, Integer> result = mapOf(String.class,
Integer.class);
+ Map<String, Integer> result = mapOf(String.class,
Integer.class);
assertNotNull(result);
assertTrue(result.isEmpty());
result.put("a", 1); // Modifiable
@@ -1069,7 +1069,7 @@ class CollectionUtils_Test extends TestBase {
//====================================================================================================
@Test
void a063_set() {
- LinkedHashSet<String> result = set("a", "b", "c");
+ Set<String> result = set("a", "b", "c");
assertNotNull(result);
assertEquals(3, result.size());
assertTrue(result.contains("a"));
@@ -1097,7 +1097,7 @@ class CollectionUtils_Test extends TestBase {
//====================================================================================================
@Test
void a065_setOf() {
- LinkedHashSet<String> result = setOf(String.class, "a", "b",
"c");
+ Set<String> result = setOf(String.class, "a", "b", "c");
assertNotNull(result);
assertEquals(3, result.size());
assertTrue(result.contains("a"));
@@ -1153,7 +1153,7 @@ class CollectionUtils_Test extends TestBase {
//====================================================================================================
@Test
void a070_sortedMap() {
- TreeMap<String, Integer> result = sortedMap();
+ SortedMap<String, Integer> result = sortedMap();
assertNotNull(result);
assertTrue(result.isEmpty());
result.put("a", 1);
@@ -1165,22 +1165,22 @@ class CollectionUtils_Test extends TestBase {
//====================================================================================================
@Test
void a071_sortedSet() {
- TreeSet<String> result = sortedSet("c", "a", "b");
+ SortedSet<String> result = sortedSet("c", "a", "b");
assertNotNull(result);
assertEquals(3, result.size());
assertEquals(list("a", "b", "c"), new ArrayList<>(result));
// Empty
- TreeSet<String> empty = sortedSet();
+ SortedSet<String> empty = sortedSet();
assertNotNull(empty);
assertTrue(empty.isEmpty());
// Single
- TreeSet<String> single = sortedSet("a");
+ SortedSet<String> single = sortedSet("a");
assertEquals(1, single.size());
// Numbers
- TreeSet<Integer> numbers = sortedSet(3, 1, 2, 5, 4);
+ SortedSet<Integer> numbers = sortedSet(3, 1, 2, 5, 4);
assertEquals(list(1, 2, 3, 4, 5), new ArrayList<>(numbers));
}
@@ -1257,7 +1257,7 @@ class CollectionUtils_Test extends TestBase {
@Test
void a077_toList_collection() {
Collection<String> col = set("a", "b", "c");
- ArrayList<String> result = toList(col);
+ List<String> result = toList(col);
assertNotNull(result);
assertEquals(3, result.size());
assertTrue(result.contains("a"));
@@ -1269,11 +1269,11 @@ class CollectionUtils_Test extends TestBase {
@Test
void a078_toList_collectionBoolean() {
Collection<String> col = list("a", "b");
- ArrayList<String> result1 = toList(col, false);
+ List<String> result1 = toList(col, false);
assertNotNull(result1);
assertEquals(2, result1.size());
- ArrayList<String> result2 = toList(col, true);
+ List<String> result2 = toList(col, true);
assertNotNull(result2);
assertEquals(2, result2.size());
@@ -1375,13 +1375,13 @@ class CollectionUtils_Test extends TestBase {
//====================================================================================================
@Test
void a081_toSortedSet() {
- LinkedHashSet<String> input = new LinkedHashSet<>(l("c", "a",
"b"));
- TreeSet<String> result = toSortedSet(input);
+ Set<String> input = new LinkedHashSet<>(l("c", "a", "b"));
+ SortedSet<String> result = toSortedSet(input);
assertNotNull(result);
assertEquals(l("a", "b", "c"), new ArrayList<>(result));
- LinkedHashSet<Integer> input2 = new LinkedHashSet<>(l(3, 1, 2));
- TreeSet<Integer> result2 = toSortedSet(input2);
+ Set<Integer> input2 = new LinkedHashSet<>(l(3, 1, 2));
+ SortedSet<Integer> result2 = toSortedSet(input2);
assertEquals(l(1, 2, 3), new ArrayList<>(result2));
assertNotNull(toSortedSet((Set<String>)null));
@@ -1467,12 +1467,12 @@ class CollectionUtils_Test extends TestBase {
void a085b_toSortedSet_collection() {
// Test lines 2117-2121: toSortedSet(Collection<E>) - different
from toSortedSet(Set<E>)
Collection<String> col = list("c", "a", "b");
- TreeSet<String> result = toSortedSet(col);
+ SortedSet<String> result = toSortedSet(col);
assertNotNull(result);
assertEquals(l("a", "b", "c"), new ArrayList<>(result));
Collection<Integer> col2 = list(3, 1, 2);
- TreeSet<Integer> result2 = toSortedSet(col2);
+ SortedSet<Integer> result2 = toSortedSet(col2);
assertEquals(l(1, 2, 3), new ArrayList<>(result2));
// Test line 2117: null returns empty TreeSet
@@ -1486,7 +1486,7 @@ class CollectionUtils_Test extends TestBase {
@Test
void a086_toSortedSet_collectionBoolean() {
Collection<String> col = list("c", "a", "b");
- TreeSet<String> result1 = toSortedSet(col, false);
+ SortedSet<String> result1 = toSortedSet(col, false);
assertNotNull(result1);
assertEquals(3, result1.size());
@@ -1563,7 +1563,7 @@ class CollectionUtils_Test extends TestBase {
//====================================================================================================
@Test
void a092_al() {
- ArrayList<String> list = al("a", "b", "c");
+ List<String> list = al("a", "b", "c");
assertNotNull(list);
assertEquals(3, list.size());
assertEquals("a", list.get(0));
@@ -1571,7 +1571,7 @@ class CollectionUtils_Test extends TestBase {
assertEquals("c", list.get(2));
// Empty list
- ArrayList<String> empty = al();
+ List<String> empty = al();
assertNotNull(empty);
assertEquals(0, empty.size());
@@ -1585,7 +1585,7 @@ class CollectionUtils_Test extends TestBase {
//====================================================================================================
@Test
void a093_ll() {
- LinkedList<String> list = ll("a", "b", "c");
+ List<String> list = ll("a", "b", "c");
assertNotNull(list);
assertEquals(3, list.size());
assertEquals("a", list.get(0));
@@ -1593,7 +1593,7 @@ class CollectionUtils_Test extends TestBase {
assertEquals("c", list.get(2));
// Empty list
- LinkedList<String> empty = ll();
+ List<String> empty = ll();
assertNotNull(empty);
assertEquals(0, empty.size());
@@ -1607,7 +1607,7 @@ class CollectionUtils_Test extends TestBase {
//====================================================================================================
@Test
void a094_hs() {
- HashSet<String> set = hs("a", "b", "c");
+ Set<String> set = hs("a", "b", "c");
assertNotNull(set);
assertEquals(3, set.size());
assertTrue(set.contains("a"));
@@ -1615,7 +1615,7 @@ class CollectionUtils_Test extends TestBase {
assertTrue(set.contains("c"));
// Empty set
- HashSet<String> empty = hs();
+ Set<String> empty = hs();
assertNotNull(empty);
assertEquals(0, empty.size());
@@ -1633,7 +1633,7 @@ class CollectionUtils_Test extends TestBase {
//====================================================================================================
@Test
void a095_ts() {
- TreeSet<String> set = ts("c", "a", "b");
+ SortedSet<String> set = ts("c", "a", "b");
assertNotNull(set);
assertEquals(3, set.size());
// TreeSet is sorted
@@ -1641,7 +1641,7 @@ class CollectionUtils_Test extends TestBase {
assertEquals("c", set.last());
// Empty set
- TreeSet<String> empty = ts();
+ SortedSet<String> empty = ts();
assertNotNull(empty);
assertEquals(0, empty.size());
@@ -1655,7 +1655,7 @@ class CollectionUtils_Test extends TestBase {
assertEquals(4, set.size());
// Sorted order
- TreeSet<Integer> intSet = ts(3, 1, 2);
+ SortedSet<Integer> intSet = ts(3, 1, 2);
assertEquals(1, intSet.first());
assertEquals(3, intSet.last());
}