List<RedeemActivity> redeemActivitiesOfPrize = activities.stream()
.filter(x -> activityIdsOfPrize.contains(x.getId())).collect(Collectors.toList());
userCOS.stream() .sorted(Comparator.comparing(userCO::getCreateDate).reversed()).collect(Collectors.toList());
List<String> userIds = users.stream().collect(() -> new ArrayList<String>(), (list, user) -> list.add(user.getId()), (list1, list2) -> list1.addAll(list2));
List<String> orderNos = orderStatus.stream().map(OrderDetail::getOrderNo).collect(toList());
List<CommodityActivityRule> excludedCommodityActivityRules = Optional.ofNullable(commodityActivityRules)
.orElseGet(ArrayList::new).stream()
.filter(commodityActivityRule -> !commodityActivityRule.getActivity().getId().equals(activityId))
.collect(Collectors.toList());
Optional.of(marketingConfigRepository.listAll(new MarketingConfig())).orElseGet(ArrayList::new).stream()
.filter(marketingConfig -> excludedMarketingConfigTypes.contains(marketingConfig.getType()))
.map(MarketingConfig::getId).collect(Collectors.toList());
Optional.ofNullable(usageRules).orElseGet(ArrayList::new)
BigDecimal commodityAmount = orderDetails.stream().map(OrderDetail::getCommodityAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
Optional<GradeThresholdInfoCO> nextOptional = gradeThresholdList.stream().filter(x -> x.getLevel() != null && x.getLevel() == level + 1).findFirst();
if (nextOptional.isPresent()) {
return nextOptional.get();
}
List<Cookie> targetCookies = Optional.ofNullable(cookies).orElseGet(ArrayList::new).stream()
.filter(e -> "jsessionid".equalsIgnoreCase(e.getName())).collect(Collectors.toList());
log.info("Cookie名称为:{}的值为:{}", "jsessionid",
Optional.ofNullable(targetCookies).orElseGet(ArrayList::new).get(0).getValue());
Optional<Cookie> first = Optional.ofNullable(cookies).orElseGet(ArrayList::new).stream()
.filter(e -> "jsessionid".equalsIgnoreCase(e.getName())).findFirst();
if (first.isPresent()) {
log.info("Cookie名称为:{}的值为:{}", "jsessionid",
first.get().getValue());
}
Optional<Optional<Integer>> maxLevelOptional = ruleList.stream().map(x -> x.getEarningRuleMap().keySet().stream().max((o1, o2) -> o1.compareTo(o2))).max((o1, o2) -> {
Integer value1 = o1.isPresent() ? o1.get() : 0;
Integer value2 = o2.isPresent() ? o2.get() : 0;
return value1.compareTo(value2);
});
Optional<ActivityVO> max = activityVOS.stream().max(Comparator.comparing(ActivityVO::getEndDate));
Optional<ActivityVO> min = activityVOS.stream().min(Comparator.comparing(ActivityVO::getStartDate));
Date maxEndDate = max.get().getEndDate();
Date minStartDate = min.get().getStartDate();
Map<PrizeType, List<RedeemActivityPrize>> prizeTypeAndPrizesMap = redeemActivityPrize.stream().collect(Collectors.groupingBy(RedeemActivityPrize::getPrizeType));
List<RedeemActivityPrize> couponPrizes = prizeTypeAndPrizesMap.get(PrizeType.COUPON);
List<RedeemActivityPrize> presentPrizes = prizeTypeAndPrizesMap.get(PrizeType.PRESENT);
prizes.stream().collect(Collectors.groupingBy(RedeemActivityPrize::getPrizeId))
.forEach((prizeId, activityPrizes) -> {
List<String> activityIdsOfPrize = activityPrizes.stream()
.map(RedeemActivityPrize::getRedeemActivityId).collect(Collectors.toList());
List<RedeemActivity> redeemActivitiesOfPrize = activities.stream()
.filter(x -> activityIdsOfPrize.contains(x.getId())).collect(Collectors.toList());
List<RedeemActivityBriefCO> briefCOS = ModelConvertorHelper.convertList(redeemActivitiesOfPrize,
RedeemActivityBriefCO.class);
RedeemUsedPresentCO co = new RedeemUsedPresentCO();
co.setPresentId(prizeId);
co.setActivities(briefCOS);
result.add(co);
});
private static <T, R> List<R> transform(List<T> list, Function<T, R> fx) {
List<R> result = new ArrayList<>();
for (T element : list) {
result.add(fx.apply(element));
}
return result;
}
List<Integer> namesLength = transform(names, String::length);
Stream.of(task1, task2, task3, task4, task5).collect(toList())
tasks.stream().filter(task -> task.getType() == TaskType.READING).sorted(comparing(Task::getCreatedOn)).map(Task::getTitle).
limit(n).collect(toList());
couponIds.forEach(x -> {
RedeemActivityPrize presentRedeem = new RedeemActivityPrize();
presentRedeem.setRedeemActivityId(redeemActivityId);
presentRedeem.setPrizeType(PrizeType.COUPON);
presentRedeem.setPrizeId(x);
redeemActivityPrizeList.add(presentRedeem);
});