com.azure.cosmos.TransactionalBatchOperationResult Maven / Gradle / Ivy
Show all versions of azure-cosmos Show documentation
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.cosmos;
import com.azure.cosmos.implementation.JsonSerializable;
import com.azure.cosmos.util.Beta;
import com.fasterxml.jackson.databind.node.ObjectNode;
import java.time.Duration;
import static com.azure.cosmos.implementation.guava25.base.Preconditions.checkNotNull;
/**
*
* @deprecated forRemoval = true, since = "4.19"
* This class is not necessary anymore and will be removed. Please use {@link com.azure.cosmos.models.CosmosBatchOperationResult}
*
* Represents a result for a specific operation that was part of a {@link TransactionalBatch} request.
*/
@Beta(value = Beta.SinceVersion.V4_7_0, warningText = Beta.PREVIEW_SUBJECT_TO_CHANGE_WARNING)
@Deprecated() //forRemoval = true, since = "4.19"
@SuppressWarnings("DeprecatedIsStillUsed")
public final class TransactionalBatchOperationResult {
private final String eTag;
private final double requestCharge;
private final ObjectNode resourceObject;
private final int statusCode;
private final Duration retryAfter;
private final int subStatusCode;
private final CosmosItemOperation cosmosItemOperation;
/**
* Initializes a new instance of the {@link TransactionalBatchOperationResult} class.
*/
TransactionalBatchOperationResult(String eTag,
double requestCharge,
ObjectNode resourceObject,
int statusCode,
Duration retryAfter,
int subStatusCode,
CosmosItemOperation cosmosItemOperation) {
checkNotNull(statusCode, "expected non-null statusCode");
checkNotNull(cosmosItemOperation, "expected non-null cosmosItemOperation");
this.eTag = eTag;
this.requestCharge = requestCharge;
this.resourceObject = resourceObject;
this.statusCode = statusCode;
this.retryAfter = retryAfter;
this.subStatusCode = subStatusCode;
this.cosmosItemOperation = cosmosItemOperation;
}
/**
* Gets the entity tag associated with the current item.
*
* ETags are used for concurrency checking when updating resources.
*
* @return Entity tag associated with the current item.
*/
@Beta(value = Beta.SinceVersion.V4_7_0, warningText = Beta.PREVIEW_SUBJECT_TO_CHANGE_WARNING)
@Deprecated() //forRemoval = true, since = "4.19"
public String getETag() {
return this.eTag;
}
/**
* Gets the request charge as request units (RU) consumed by the current operation.
*
* For more information about the RU and factors that can impact the effective charges please visit
* Request Units in Azure Cosmos DB
*
* @return the request charge.
*/
@Beta(value = Beta.SinceVersion.V4_7_0, warningText = Beta.PREVIEW_SUBJECT_TO_CHANGE_WARNING)
@Deprecated() //forRemoval = true, since = "4.19"
public double getRequestCharge() {
return this.requestCharge;
}
/**
* Gets the item associated with the current result.
*
* @param the type parameter
*
* @param type class type for which deserialization is needed.
*
* @return item associated with the current result.
*/
@Beta(value = Beta.SinceVersion.V4_7_0, warningText = Beta.PREVIEW_SUBJECT_TO_CHANGE_WARNING)
@Deprecated() //forRemoval = true, since = "4.19"
public T getItem(final Class type) {
T item = null;
if (this.getResourceObject() != null) {
item = new JsonSerializable(this.getResourceObject()).toObject(type);
}
return item;
}
/**
* Gets retry after.
*
* @return the retry after
*/
@Beta(value = Beta.SinceVersion.V4_7_0, warningText = Beta.PREVIEW_SUBJECT_TO_CHANGE_WARNING)
@Deprecated() //forRemoval = true, since = "4.19"
public Duration getRetryAfterDuration() {
return this.retryAfter;
}
/**
* Gets sub status code associated with the current result.
*
* @return the sub status code
*/
@Beta(value = Beta.SinceVersion.V4_7_0, warningText = Beta.PREVIEW_SUBJECT_TO_CHANGE_WARNING)
@Deprecated() //forRemoval = true, since = "4.19"
public int getSubStatusCode() {
return this.subStatusCode;
}
/**
* Gets a value indicating whether the current operation completed successfully.
*
* @return {@code true} if the current operation completed successfully; {@code false} otherwise.
*/
@Beta(value = Beta.SinceVersion.V4_7_0, warningText = Beta.PREVIEW_SUBJECT_TO_CHANGE_WARNING)
@Deprecated() //forRemoval = true, since = "4.19"
public boolean isSuccessStatusCode() {
return 200 <= this.statusCode && this.statusCode <= 299;
}
/**
* Gets the HTTP status code associated with the current result.
*
* @return the status code.
*/
@Beta(value = Beta.SinceVersion.V4_7_0, warningText = Beta.PREVIEW_SUBJECT_TO_CHANGE_WARNING)
@Deprecated() //forRemoval = true, since = "4.19"
public int getStatusCode() {
return this.statusCode;
}
ObjectNode getResourceObject() {
return resourceObject;
}
/**
* Gets the original operation for this result.
*
* @return the CosmosItemOperation.
*/
@Beta(value = Beta.SinceVersion.V4_7_0, warningText = Beta.PREVIEW_SUBJECT_TO_CHANGE_WARNING)
@Deprecated() //forRemoval = true, since = "4.19"
public CosmosItemOperation getOperation() {
return cosmosItemOperation;
}
}