Code review comment: Got it. We can always replace deliveryPolicy with `standardRulesEngineRuleMap`.

Code before review:
public Mono<CdnEndpoint> updateResourceAsync() {
final CdnEndpointImpl self = this;
EndpointUpdateParameters endpointUpdateParameters = new EndpointUpdateParameters();
endpointUpdateParameters.withIsHttpAllowed(this.innerModel().isHttpAllowed())
.withIsHttpsAllowed(this.innerModel().isHttpsAllowed())
.withOriginPath(this.innerModel().originPath())
.withOriginHostHeader(this.innerModel().originHostHeader())
.withIsCompressionEnabled(this.innerModel().isCompressionEnabled())
.withContentTypesToCompress(this.innerModel().contentTypesToCompress())
.withGeoFilters(this.innerModel().geoFilters())
.withOptimizationType(this.innerModel().optimizationType())
.withQueryStringCachingBehavior(this.innerModel().queryStringCachingBehavior())
.withTags(this.innerModel().tags());
if (isStandardMicrosoftSku()) {
List<DeliveryRule> rules = this.standardRulesEngineRuleMap.values()
.stream()
.sorted(Comparator.comparingInt(DeliveryRule::order))
.collect(Collectors.toList());
if (innerModel().deliveryPolicy() == null && !CoreUtils.isNullOrEmpty(this.standardRulesEngineRuleMap)) {
endpointUpdateParameters.withDeliveryPolicy(
new EndpointPropertiesUpdateParametersDeliveryPolicy()
.withRules(rules));
} else if (innerModel().deliveryPolicy() != null) {
endpointUpdateParameters.withDeliveryPolicy(
innerModel().deliveryPolicy()
.withRules(rules));
}
}
DeepCreatedOrigin originInner = this.innerModel().origins().get(0);
OriginUpdateParameters originUpdateParameters = new OriginUpdateParameters()
.withHostname(originInner.hostname())
.withHttpPort(originInner.httpPort())
.withHttpsPort(originInner.httpsPort());
Mono<EndpointInner> originUpdateTask = this.parent().manager().serviceClient().getOrigins().updateAsync(
this.parent().resourceGroupName(),
this.parent().name(),
this.name(),
originInner.name(),
originUpdateParameters)
.then(Mono.empty());
Mono<EndpointInner> endpointUpdateTask = this.parent().manager().serviceClient().getEndpoints().updateAsync(
this.parent().resourceGroupName(),
this.parent().name(),
this.name(),
endpointUpdateParameters);
Flux<CustomDomainInner> customDomainCreateTask = Flux.fromIterable(this.customDomainList)
.flatMapDelayError(itemToCreate -> this.parent().manager().serviceClient().getCustomDomains().createAsync(
this.parent().resourceGroupName(),
this.parent().name(),
this.name(),
self.parent().manager().resourceManager().internalContext()
.randomResourceName("CustomDomain", 50),
new CustomDomainParameters().withHostname(itemToCreate.hostname())
), 32, 32);
Flux<CustomDomainInner> customDomainDeleteTask = Flux.fromIterable(this.deletedCustomDomainList)
.flatMapDelayError(itemToDelete -> this.parent().manager().serviceClient().getCustomDomains().deleteAsync(
this.parent().resourceGroupName(),
this.parent().name(),
this.name(),
itemToDelete.name()
), 32, 32);
Mono<EndpointInner> customDomainTask = Flux.concat(customDomainCreateTask, customDomainDeleteTask)
.then(Mono.empty());
return Flux.mergeDelayError(32, customDomainTask, originUpdateTask, endpointUpdateTask)
.last()
.map(inner -> {
self.setInner(inner);
self.customDomainList.clear();
self.deletedCustomDomainList.clear();
return self;
});
}

Line under review: }

Code after addressing the review:
public Mono<CdnEndpoint> updateResourceAsync() {
final CdnEndpointImpl self = this;
EndpointUpdateParameters endpointUpdateParameters = new EndpointUpdateParameters();
endpointUpdateParameters.withIsHttpAllowed(this.innerModel().isHttpAllowed())
.withIsHttpsAllowed(this.innerModel().isHttpsAllowed())
.withOriginPath(this.innerModel().originPath())
.withOriginHostHeader(this.innerModel().originHostHeader())
.withIsCompressionEnabled(this.innerModel().isCompressionEnabled())
.withContentTypesToCompress(this.innerModel().contentTypesToCompress())
.withGeoFilters(this.innerModel().geoFilters())
.withOptimizationType(this.innerModel().optimizationType())
.withQueryStringCachingBehavior(this.innerModel().queryStringCachingBehavior())
.withTags(this.innerModel().tags());
if (isStandardMicrosoftSku()) {
List<DeliveryRule> rules = this.standardRulesEngineRuleMap.values()
.stream()
.sorted(Comparator.comparingInt(DeliveryRule::order))
.collect(Collectors.toList());
ensureDeliveryPolicy();
endpointUpdateParameters.withDeliveryPolicy(
new EndpointPropertiesUpdateParametersDeliveryPolicy()
.withRules(rules));
}
DeepCreatedOrigin originInner = this.innerModel().origins().get(0);
OriginUpdateParameters originUpdateParameters = new OriginUpdateParameters()
.withHostname(originInner.hostname())
.withHttpPort(originInner.httpPort())
.withHttpsPort(originInner.httpsPort());
Mono<EndpointInner> originUpdateTask = this.parent().manager().serviceClient().getOrigins().updateAsync(
this.parent().resourceGroupName(),
this.parent().name(),
this.name(),
originInner.name(),
originUpdateParameters)
.then(Mono.empty());
Mono<EndpointInner> endpointUpdateTask = this.parent().manager().serviceClient().getEndpoints().updateAsync(
this.parent().resourceGroupName(),
this.parent().name(),
this.name(),
endpointUpdateParameters);
Flux<CustomDomainInner> customDomainCreateTask = Flux.fromIterable(this.customDomainList)
.flatMapDelayError(itemToCreate -> this.parent().manager().serviceClient().getCustomDomains().createAsync(
this.parent().resourceGroupName(),
this.parent().name(),
this.name(),
self.parent().manager().resourceManager().internalContext()
.randomResourceName("CustomDomain", 50),
new CustomDomainParameters().withHostname(itemToCreate.hostname())
), 32, 32);
Flux<CustomDomainInner> customDomainDeleteTask = Flux.fromIterable(this.deletedCustomDomainList)
.flatMapDelayError(itemToDelete -> this.parent().manager().serviceClient().getCustomDomains().deleteAsync(
this.parent().resourceGroupName(),
this.parent().name(),
this.name(),
itemToDelete.name()
), 32, 32);
Mono<EndpointInner> customDomainTask = Flux.concat(customDomainCreateTask, customDomainDeleteTask)
.then(Mono.empty());
return Flux.mergeDelayError(32, customDomainTask, originUpdateTask, endpointUpdateTask)
.last()
.map(inner -> {
self.setInner(inner);
self.customDomainList.clear();
self.deletedCustomDomainList.clear();
return self;
});
}