@Test public void testElementAndList() throws Exception { List<Object> list = CompoundList.of(first, Arrays.asList(second, third, forth)); assertThat(list.size(), is(4)); assertThat(list.get(0), is(first)); assertThat(list.get(1), is(second)); assertThat(list.get(2), is(third)); assertThat(list.get(3), is(forth)); }
public static <S> List<S> of(S left, List<? extends S> right) { if (right.isEmpty()) { return Collections.singletonList(left); } else { List<S> list = new ArrayList<S>(1 + right.size()); list.add(left); list.addAll(right); return list; } }
CompoundList { public static <S> List<S> of(S left, List<? extends S> right) { if (right.isEmpty()) { return Collections.singletonList(left); } else { List<S> list = new ArrayList<S>(1 + right.size()); list.add(left); list.addAll(right); return list; } } }
CompoundList { public static <S> List<S> of(S left, List<? extends S> right) { if (right.isEmpty()) { return Collections.singletonList(left); } else { List<S> list = new ArrayList<S>(1 + right.size()); list.add(left); list.addAll(right); return list; } } private  CompoundList(); }
CompoundList { public static <S> List<S> of(S left, List<? extends S> right) { if (right.isEmpty()) { return Collections.singletonList(left); } else { List<S> list = new ArrayList<S>(1 + right.size()); list.add(left); list.addAll(right); return list; } } private  CompoundList(); static List<S> of(S left, List<? extends S> right); static List<S> of(List<? extends S> left, S right); static List<S> of(List<? extends S> left, List<? extends S> right); static List<S> of(List<? extends S> left, List<? extends S> middle, List<? extends S> right); }
CompoundList { public static <S> List<S> of(S left, List<? extends S> right) { if (right.isEmpty()) { return Collections.singletonList(left); } else { List<S> list = new ArrayList<S>(1 + right.size()); list.add(left); list.addAll(right); return list; } } private  CompoundList(); static List<S> of(S left, List<? extends S> right); static List<S> of(List<? extends S> left, S right); static List<S> of(List<? extends S> left, List<? extends S> right); static List<S> of(List<? extends S> left, List<? extends S> middle, List<? extends S> right);  }