OiO.lk Blog java How can I mapToObj for two IntStreams?
java

How can I mapToObj for two IntStreams?


Say, I have two method which each returns an IntStream.

static IntStream getKeySizeStream() {
    return IntStream.of(
            128,
            192,
            256
    );
}

static IntStream getBlockSizeStream() {
    return IntStream.of(
            128
    );
}

I want to define a new method which returns a stream of combination of these two streams.

And a way that I found is this.

static Stream<Arguments> getKeySizeAndBlockSizeArgumentsStream() {
    return getKeySizeStream().boxed().flatMap(ks -> {
        return getBlockSizeStream()
                .mapToObj(bs -> Arguments.of(ks, bs));
    });
}

How can I do without the .boxed().map() part? Can I do that?



You need to sign in to view this answers

Exit mobile version