mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-06 03:50:02 +02:00
GT-3354: Code review fixes
This commit is contained in:
parent
2a64cf2a77
commit
e53e4c99fc
5 changed files with 34 additions and 10 deletions
|
@ -398,6 +398,19 @@ public class CollectionUtils {
|
|||
return () -> iterator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Combines all collections passed-in into a pass-through not creating a new collection)
|
||||
* Iterable.
|
||||
*
|
||||
* @param iterables the iterables to combine
|
||||
* @return the iterable
|
||||
*/
|
||||
@SafeVarargs
|
||||
public static <T> Iterable<T> asIterable(Iterable<T>... iterables) {
|
||||
Stream<T> s = asStream(iterables);
|
||||
return asIterable(s.iterator());
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns the given iterator into a stream
|
||||
*
|
||||
|
|
|
@ -225,6 +225,21 @@ public class CollectionUtilsTest {
|
|||
assertEquals("One", iterator.next());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAsIterable_Collections() {
|
||||
|
||||
List<String> original = Arrays.asList("One", "Two", "Three", "Four");
|
||||
Collection<String> a = Arrays.asList(original.get(0), original.get(1));
|
||||
Collection<String> b = Arrays.asList(original.get(2));
|
||||
Collection<String> c = Collections.emptyList();
|
||||
Collection<String> d = Arrays.asList(original.get(3));
|
||||
Iterable<String> iterable = CollectionUtils.asIterable(a, b, c, d);
|
||||
|
||||
List<String> result = new ArrayList<>();
|
||||
iterable.forEach(s -> result.add(s));
|
||||
assertEquals(original, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAsList_UnknownToType() {
|
||||
List<String> list = new ArrayList<>();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue