2014-04-01 08:36:34 -04:00
|
|
|
|
2014-04-19 02:30:29 -04:00
|
|
|
package net.filebot.util;
|
2014-04-01 08:36:34 -04:00
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Collection;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
public class TestUtil {
|
2015-07-25 18:47:19 -04:00
|
|
|
|
2014-04-01 08:36:34 -04:00
|
|
|
public static List<Object[]> asParameters(Object... parameters) {
|
|
|
|
List<Object[]> list = new ArrayList<Object[]>();
|
2015-07-25 18:47:19 -04:00
|
|
|
|
2014-04-01 08:36:34 -04:00
|
|
|
for (Object parameter : parameters) {
|
|
|
|
list.add(new Object[] { parameter });
|
|
|
|
}
|
2015-07-25 18:47:19 -04:00
|
|
|
|
2014-04-01 08:36:34 -04:00
|
|
|
return list;
|
|
|
|
}
|
2015-07-25 18:47:19 -04:00
|
|
|
|
2014-04-01 08:36:34 -04:00
|
|
|
|
|
|
|
public static List<Object[]> asParameters(Collection<?> parameters) {
|
|
|
|
return asParameters(parameters.toArray());
|
|
|
|
}
|
2015-07-25 18:47:19 -04:00
|
|
|
|
2014-04-01 08:36:34 -04:00
|
|
|
|
|
|
|
public static <T> List<List<T>> rotations(Collection<T> source) {
|
|
|
|
List<List<T>> rotations = new ArrayList<List<T>>();
|
2015-07-25 18:47:19 -04:00
|
|
|
|
2014-04-01 08:36:34 -04:00
|
|
|
for (int i = 0; i < source.size(); i++) {
|
|
|
|
List<T> copy = new ArrayList<T>(source);
|
|
|
|
Collections.rotate(copy, i);
|
|
|
|
rotations.add(copy);
|
|
|
|
}
|
2015-07-25 18:47:19 -04:00
|
|
|
|
2014-04-01 08:36:34 -04:00
|
|
|
return rotations;
|
|
|
|
}
|
2015-07-25 18:47:19 -04:00
|
|
|
|
2014-04-01 08:36:34 -04:00
|
|
|
}
|