List of usage examples for com.google.common.collect Collections2 orderedPermutations
@Beta public static <E extends Comparable<? super E>> Collection<List<E>> orderedPermutations(Iterable<E> elements)
From source file:org.cakeframework.test.container.tck.RunState.java
/** * Returns a parameterized combination of all run states. * /*from w ww.j a va2s . co m*/ * @return */ public static Collection<Object[]> getAllStateCombinations() { // Test all combinations Collection<List<RunState>> subSets = Collections2.orderedPermutations( Arrays.asList(RunState.INITIALIZED, RunState.STARTING, RunState.RUNNING, RunState.SHUTDOWN)); ArrayList<Object[]> l = new ArrayList<>(); HashSet<Collection<RunState>> lhs = new HashSet<>(); for (int i = 1; i <= 4; i++) { for (List<RunState> li : subSets) { Collection<RunState> c = new TreeSet<>(li.subList(0, i)); if (lhs.add(c)) { l.add(new Object[] { c }); } } } assertEquals(15, l.size()); return l; }