I am new to Java8 syntax, How can we get the output as list after filtered. In my case filter returns an array.
Added in comments, is there any better way can we get it
Config config = new Config("ooo", "wc", "code");
Config config1 = new Config("ppp", "wc", "code");
Config config2 = new Config("ooo", "wc", "code");
Config[] configs = {config, config1, config2};
Config config4 = new Config("ooo", "REG", "code");
Config config5 = new Config("ppp", "REG", "code");
Config config6 = new Config("ooo", "REG", "code");
Config[] _configs = {config4, config5, config6};
PromoCode promoCode = new PromoCode(121, "VOUCHER", "121", configs);
PromoCode promoCode1 = new PromoCode(122, "VOUCHER", "122", null);
PromoCode promoCode2 = new PromoCode(123, "LINK", "123", configs);
PromoCode promoCode3 = new PromoCode(124, "VOUCHER", "124", null);
PromoCode promoCode4 = new PromoCode(125, "LINK", "125", _configs);
PromoCode promoCode5 = new PromoCode(126, "LINK", "126", _configs);
List<String> resultantValues = new ArrayList<String>();
PromoCode[] promoCodes = {promoCode, promoCode1, promoCode2, promoCode3, promoCode4, promoCode5};
Stream<PromoCode> stream = Stream.of(promoCodes);
stream.parallel()
.filter(x -> x.getCode().equalsIgnoreCase("VOUCHER"))
.collect(Collectors.toList())
.parallelStream()
.forEach(x-> {
Stream.of(x.getConfigs())
.filter(t -> t.getOccasion().equals("wc"))
//after filter, how can we get the output
// List of list of strings format
.forEach(o -> {
resultantValues.add(o.getProduct()+"_"+o.getProduct());
});
});
System.out.println(resultantValues);