Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class Iterators {
* @return a new {@link ConcatenatedIterator}
* @throws NullPointerException if iterators is null
*/
@SafeVarargs
public static <T> Iterator<T> concat(Iterator<? extends T>... iterators) {
if (iterators == null) {
throw new NullPointerException("iterators");
Expand All @@ -68,6 +69,7 @@ static class ConcatenatedIterator<T> implements Iterator<T> {
private final Iterator<? extends T>[] iterators;
private int index = 0;

@SafeVarargs
ConcatenatedIterator(Iterator<? extends T>... iterators) {
if (iterators == null) {
throw new NullPointerException("iterators");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public static <T> HashSet<T> newHashSet(Iterable<T> iterable) {
return iterable instanceof Collection<T> collection ? new HashSet<>(collection) : newHashSet(iterable.iterator());
}

@SafeVarargs
public static <T> HashSet<T> newHashSet(T... elements) {
Objects.requireNonNull(elements);
HashSet<T> set = new HashSet<>(elements.length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ private <T> Iterator<T> singletonIterator(T value) {
return Collections.singleton(value).iterator();
}

@SafeVarargs
private <T> void assertSingleton(T value, Iterator<T>... iterators) {
Iterator<T> concat = Iterators.concat(iterators);
assertContainsInOrder(concat, value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ public static IOException unwrapCorruption(Throwable t) {
* @param clazzes Classes to look for
* @return Matching Throwable if one is found, otherwise {@code null}
*/
@SafeVarargs
public static Throwable unwrap(Throwable t, Class<?>... clazzes) {
if (t != null) {
final Set<Throwable> seen = Collections.newSetFromMap(new IdentityHashMap<>());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ public static void ensureNoSelfReferences(Object value, String messageHint) {
* @param value The object to convert
* @return The Iterable, or null if the object cannot be converted
*/
@SuppressWarnings("unchecked")
private static Iterable<?> convert(Object value) {
return switch (value) {
case Map<?, ?> map -> () -> Iterators.concat(map.keySet().iterator(), map.values().iterator());
Expand Down Expand Up @@ -268,15 +267,15 @@ public static <E> ArrayList<E> iterableAsArrayList(Iterable<? extends E> element
}
}

@SuppressWarnings("unchecked")
@SafeVarargs
public static <E> ArrayList<E> arrayAsArrayList(E... elements) {
if (elements == null) {
throw new NullPointerException("elements");
}
return new ArrayList<>(Arrays.asList(elements));
}

@SuppressWarnings("unchecked")
@SafeVarargs
public static <E> ArrayList<E> asArrayList(E first, E... other) {
if (other == null) {
throw new NullPointerException("other");
Expand All @@ -287,7 +286,7 @@ public static <E> ArrayList<E> asArrayList(E first, E... other) {
return list;
}

@SuppressWarnings("unchecked")
@SafeVarargs
public static <E> ArrayList<E> asArrayList(E first, E second, E... other) {
if (other == null) {
throw new NullPointerException("other");
Expand Down
Loading