@Test public void testGenerateTwo() { LinkedList<LinkedList<Object>> input = new LinkedList<LinkedList<Object>>(){{ LinkedList<Object> axe1= new LinkedList<>(); axe1.add(1); axe1.add(2); axe1.add(3); add(axe1); LinkedList<Object> axe2= new LinkedList<>(); axe2.add("a"); axe2.add("b"); axe2.add("c"); add(axe2); }}; LinkedList<LinkedList<Object>> expected = new LinkedList<LinkedList<Object>>(){{ LinkedList<Object> item1= new LinkedList<>(); item1.add(1); item1.add("a"); add(item1); LinkedList<Object> item2= new LinkedList<>(); item2.add(1); item2.add("b"); add(item2); LinkedList<Object> item3= new LinkedList<>(); item3.add(1); item3.add("c"); add(item3); LinkedList<Object> item4= new LinkedList<>(); item4.add(2); item4.add("a"); add(item4); LinkedList<Object> item5= new LinkedList<>(); item5.add(2); item5.add("b"); add(item5); LinkedList<Object> item6= new LinkedList<>(); item6.add(2); item6.add("c"); add(item6); LinkedList<Object> item7= new LinkedList<>(); item7.add(3); item7.add("a"); add(item7); LinkedList<Object> item8= new LinkedList<>(); item8.add(3); item8.add("b"); add(item8); LinkedList<Object> item9= new LinkedList<>(); item9.add(3); item9.add("c"); add(item9); }}; Generator<Object> gen = new Generator<>(); LinkedList<LinkedList<Object>> actual = gen.generate(input); assertEquals(expected, actual); }
public LinkedList<LinkedList<T>> generate(LinkedList<LinkedList<T>> axes){ Logger.getLogger("Generator").info("start variation generator for axes : "+axes.size()); if(axes.isEmpty()){ return new LinkedList<>(); } LinkedList<LinkedList<T>> result = new LinkedList<>(); List<T> axe = axes.removeFirst(); LinkedList<LinkedList<T>> subs = generate(axes); if(subs.isEmpty()){ for(T item : axe){ result.add(new LinkedList<T>(){{add(item);}}); } return result; } for(T item : axe){ Logger.getLogger("Generator").info("considering axe item "+ item); for(LinkedList<T> sub:subs){ LinkedList<T> clone = new LinkedList<>(sub); clone.addFirst(item); result.add(clone); } } return result; }
Generator { public LinkedList<LinkedList<T>> generate(LinkedList<LinkedList<T>> axes){ Logger.getLogger("Generator").info("start variation generator for axes : "+axes.size()); if(axes.isEmpty()){ return new LinkedList<>(); } LinkedList<LinkedList<T>> result = new LinkedList<>(); List<T> axe = axes.removeFirst(); LinkedList<LinkedList<T>> subs = generate(axes); if(subs.isEmpty()){ for(T item : axe){ result.add(new LinkedList<T>(){{add(item);}}); } return result; } for(T item : axe){ Logger.getLogger("Generator").info("considering axe item "+ item); for(LinkedList<T> sub:subs){ LinkedList<T> clone = new LinkedList<>(sub); clone.addFirst(item); result.add(clone); } } return result; } }
Generator { public LinkedList<LinkedList<T>> generate(LinkedList<LinkedList<T>> axes){ Logger.getLogger("Generator").info("start variation generator for axes : "+axes.size()); if(axes.isEmpty()){ return new LinkedList<>(); } LinkedList<LinkedList<T>> result = new LinkedList<>(); List<T> axe = axes.removeFirst(); LinkedList<LinkedList<T>> subs = generate(axes); if(subs.isEmpty()){ for(T item : axe){ result.add(new LinkedList<T>(){{add(item);}}); } return result; } for(T item : axe){ Logger.getLogger("Generator").info("considering axe item "+ item); for(LinkedList<T> sub:subs){ LinkedList<T> clone = new LinkedList<>(sub); clone.addFirst(item); result.add(clone); } } return result; } Generator(); }
Generator { public LinkedList<LinkedList<T>> generate(LinkedList<LinkedList<T>> axes){ Logger.getLogger("Generator").info("start variation generator for axes : "+axes.size()); if(axes.isEmpty()){ return new LinkedList<>(); } LinkedList<LinkedList<T>> result = new LinkedList<>(); List<T> axe = axes.removeFirst(); LinkedList<LinkedList<T>> subs = generate(axes); if(subs.isEmpty()){ for(T item : axe){ result.add(new LinkedList<T>(){{add(item);}}); } return result; } for(T item : axe){ Logger.getLogger("Generator").info("considering axe item "+ item); for(LinkedList<T> sub:subs){ LinkedList<T> clone = new LinkedList<>(sub); clone.addFirst(item); result.add(clone); } } return result; } Generator(); Pivot getPivot(); List<Pivot> smartGenerate(List<T> staticPart, 
			List<T> pivots, LinkedList<LinkedList<T>> variations); LinkedList<LinkedList<T>> generate(LinkedList<LinkedList<T>> axes); }
Generator { public LinkedList<LinkedList<T>> generate(LinkedList<LinkedList<T>> axes){ Logger.getLogger("Generator").info("start variation generator for axes : "+axes.size()); if(axes.isEmpty()){ return new LinkedList<>(); } LinkedList<LinkedList<T>> result = new LinkedList<>(); List<T> axe = axes.removeFirst(); LinkedList<LinkedList<T>> subs = generate(axes); if(subs.isEmpty()){ for(T item : axe){ result.add(new LinkedList<T>(){{add(item);}}); } return result; } for(T item : axe){ Logger.getLogger("Generator").info("considering axe item "+ item); for(LinkedList<T> sub:subs){ LinkedList<T> clone = new LinkedList<>(sub); clone.addFirst(item); result.add(clone); } } return result; } Generator(); Pivot getPivot(); List<Pivot> smartGenerate(List<T> staticPart, 
			List<T> pivots, LinkedList<LinkedList<T>> variations); LinkedList<LinkedList<T>> generate(LinkedList<LinkedList<T>> axes);  }