I want do a Cartesian product on Quarter on a year between the years specified
Year(2105, 2016) should return Quarter(2015, Q1), Quarter(2015, Q2)... Quarter(2016, Q4)
The enum representing Quarter would be
public enum Quarters {
Q1, Q2, Q3, Q4
}
and the code I'm trying to come up with is stuck as below
IntStream.rangeClosed(this.getYear(), to.getYear())
.boxed()
.map(i -> Arrays
.stream(Quarters.values())
.map(q -> new Quarter(i, q))
);
The above code return Stream<Stream<Quarter>>
which I would require to be flattened to Stream<Quarter>
any help is appreciated.