Skip to content

Instantly share code, notes, and snippets.

@vegaasen
Created May 21, 2014 09:12
Show Gist options
  • Save vegaasen/e0d52eee15a8583cdd42 to your computer and use it in GitHub Desktop.
Save vegaasen/e0d52eee15a8583cdd42 to your computer and use it in GitHub Desktop.
package com.telenor.security.sso.api.service.utils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* @author <a href="mailto:vegard.aasen@telenor.com">Vegard Aasen</a>
* @since 21:38
*/
public class CollectionUtils {
private CollectionUtils() {
}
public static <E> List<E> toList(Iterable<E> iter) {
if (iter == null || iter.iterator() == null || !iter.iterator().hasNext()) {
return Collections.emptyList();
}
final List<E> list = new ArrayList<>();
for (final E item : iter) {
list.add(item);
}
return list;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment