forked from ppwozniak/confitura-jamjars
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShelf.java
32 lines (24 loc) · 757 Bytes
/
Shelf.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package pl.allegro.itm.confitura;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Stream;
public class Shelf implements Iterable<Jar> {
private final List<Jar> jars = new ArrayList<>();
public Shelf(Jar... jars) {
this.jars.addAll(Arrays.asList(jars));
}
public Shelf(Collection<Jar> jars) {
this.jars.addAll(jars);
}
@Override
public Iterator<Jar> iterator() {
return Collections.unmodifiableCollection(jars).iterator();
}
public Stream<Jar> getJarStream() {
return Collections.unmodifiableCollection(jars).stream();
}
}