troubleshooting Question

what is CompletableFuture and CompletionStage

Avatar of Rohit Bajaj
Rohit BajajFlag for India asked on
Java EE
1 Comment1 Solution139 ViewsLast Modified:
Hi,
What is this code doing -
 private CompletionStage<Object> update(UpdateAtmEnabledRequest payload, CompletableFuture<KycInfoV2> kycInfoV2Future, boolean shouldUpdate) {
        if (shouldUpdate) {
            KycInfoV2 infoV2 = kycInfoV2Future.join();
            infoV2.getAttrs().addProperty(ATM_ENABLED, payload.getAtmEnabled());
            return kycProfileDao.upsertKycInfo(payload.getUserID(), kycInfoV2Future.join())
                .thenCompose(___ -> updateCloudcard(payload.getUserID(), payload.getIfiId(), infoV2.getPanNumber(), payload.getAtmEnabled(), infoV2.getEffectiveKycStatus()))
                .thenCompose(__ -> userProfileDao.updateKycData(payload.getUserID(), null, null, ImmutableMap.of(ATM_ENABLED, payload.getAtmEnabled().toString())))
                .thenCompose(____ -> {
                    profileUpdateRecorder.recordUpdate(payload.getUserID(), new ProfileUpdateModel()
                        .action(UPDATE)
                        .field("ATM_ENABLED")
                        .value("IFI" + payload.getIfiId() + "ATM_ENABLED" + payload.getAtmEnabled().toString()));
                    return completedFuture(null);
                });
        }
        return completedFuture(null);
    }

I need to understand more of this CompletionStage, CompletableFuture.

Thanks
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros