@Test public void shouldInterpreteVarargsConstructorAsOrderedListOfItems() { DescribedCollection<String> collection = new DescribedCollection<String>(RepositoryName.from("repository"), "1", "2"); Collection<String> collectionItems = collection.itemsList(); assertThat(collectionItems).isInstanceOf(List.class); }
public List<T> itemsList() { if (List.class.isAssignableFrom(items.getClass())) { return Collections.unmodifiableList((List<T>) items); } throw new IllegalStateException("Tried to get a non-list collection as list!"); }
DescribedCollection implements Iterable<T> { public List<T> itemsList() { if (List.class.isAssignableFrom(items.getClass())) { return Collections.unmodifiableList((List<T>) items); } throw new IllegalStateException("Tried to get a non-list collection as list!"); } }
DescribedCollection implements Iterable<T> { public List<T> itemsList() { if (List.class.isAssignableFrom(items.getClass())) { return Collections.unmodifiableList((List<T>) items); } throw new IllegalStateException("Tried to get a non-list collection as list!"); } DescribedCollection(RepositoryName source, Collection<T> items);  DescribedCollection(RepositoryName source, T... items); }
DescribedCollection implements Iterable<T> { public List<T> itemsList() { if (List.class.isAssignableFrom(items.getClass())) { return Collections.unmodifiableList((List<T>) items); } throw new IllegalStateException("Tried to get a non-list collection as list!"); } DescribedCollection(RepositoryName source, Collection<T> items);  DescribedCollection(RepositoryName source, T... items); RepositoryName source(); Collection<T> items(); List<T> itemsList(); T firstItem(); boolean isEmpty(); @Override Iterator<T> iterator(); }
DescribedCollection implements Iterable<T> { public List<T> itemsList() { if (List.class.isAssignableFrom(items.getClass())) { return Collections.unmodifiableList((List<T>) items); } throw new IllegalStateException("Tried to get a non-list collection as list!"); } DescribedCollection(RepositoryName source, Collection<T> items);  DescribedCollection(RepositoryName source, T... items); RepositoryName source(); Collection<T> items(); List<T> itemsList(); T firstItem(); boolean isEmpty(); @Override Iterator<T> iterator();  }