Skip to content

Commit

Permalink
Adding listOf templates for up to 5 items
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitor Mussatto committed Feb 21, 2022
1 parent 58af714 commit e8ce80b
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -402,5 +402,4 @@ Optional<T> after(Queue<T> queue) {

// XXX: collection.stream().noneMatch(e -> e.equals(other))
// ^ This is !collection.contains(other). Do we already rewrite variations on this?

}
Original file line number Diff line number Diff line change
Expand Up @@ -211,4 +211,52 @@ ImmutableCollection<T> after(T item) {
return ImmutableList.of(item);
}
}

static final class ImmutableListOf2<T> {
@BeforeTemplate
List<T> before(T item, T item2) {
return List.of(item, item2);
}

@AfterTemplate
ImmutableCollection<T> after(T item, T item2) {
return ImmutableList.of(item, item2);
}
}

static final class ImmutableListOf3<T> {
@BeforeTemplate
List<T> before(T i1, T i2, T i3) {
return List.of(i1, i2, i3);
}

@AfterTemplate
ImmutableCollection<T> after(T i1, T i2, T i3) {
return ImmutableList.of(i1, i2, i3);
}
}

static final class ImmutableListOf4<T> {
@BeforeTemplate
List<T> before(T i1, T i2, T i3, T i4) {
return List.of(i1, i2, i3, i4);
}

@AfterTemplate
ImmutableCollection<T> after(T i1, T i2, T i3, T i4) {
return ImmutableList.of(i1, i2, i3, i4);
}
}

static final class ImmutableListOf5<T> {
@BeforeTemplate
List<T> before(T i1, T i2, T i3, T i4, T i5) {
return List.of(i1, i2, i3, i4, i5);
}

@AfterTemplate
ImmutableCollection<T> after(T i1, T i2, T i3, T i4, T i5) {
return ImmutableList.of(i1, i2, i3, i4, i5);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,23 @@ List<String> testImmutableListOfTyped() {
return Collections.emptyList();
}

ImmutableSet<Collection<String>> testImmutableList1() {
return ImmutableSet.of(List.of("1"));
Collection<String> testImmutableListOf1() {
return List.of("1");
}

Collection<String> testImmutableListOf2() {
return List.of("1", "2");
}

Collection<String> testImmutableListOf3() {
return List.of("1", "2", "3");
}

Collection<String> testImmutableListOf4() {
return List.of("1", "2", "3", "4");
}

Collection<String> testImmutableListOf5() {
return List.of("1", "2", "3", "4", "5");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,23 @@ List<String> testImmutableListOfTyped() {
return ImmutableList.of();
}

ImmutableSet<Collection<String>> testImmutableList1() {
return ImmutableSet.of(ImmutableList.of("1"));
Collection<String> testImmutableListOf1() {
return ImmutableList.of("1");
}

Collection<String> testImmutableListOf2() {
return ImmutableList.of("1", "2");
}

Collection<String> testImmutableListOf3() {
return ImmutableList.of("1", "2", "3");
}

Collection<String> testImmutableListOf4() {
return ImmutableList.of("1", "2", "3", "4");
}

Collection<String> testImmutableListOf5() {
return ImmutableList.of("1", "2", "3", "4", "5");
}
}

0 comments on commit e8ce80b

Please sign in to comment.