Link to home
Start Free TrialLog in
Avatar of Rohit Bajaj
Rohit BajajFlag for India

asked on

what is CompletableFuture and CompletionStage

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);
    }

Open in new window


I need to understand more of this CompletionStage, CompletableFuture.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of girionis
girionis
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial