com.azure.cosmos.models.CosmosConflictProperties Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-cosmos Show documentation
Show all versions of azure-cosmos Show documentation
This Package contains Microsoft Azure Cosmos SDK (with Reactive Extension Reactor support) for Azure Cosmos DB SQL API
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.cosmos.models;
import com.azure.cosmos.implementation.Conflict;
import com.azure.cosmos.implementation.OperationKind;
import com.azure.cosmos.implementation.Resource;
import com.fasterxml.jackson.databind.node.ObjectNode;
import java.time.Instant;
import java.util.List;
import java.util.stream.Collectors;
/**
* The type Cosmos conflict properties.
*/
public final class CosmosConflictProperties {
private Conflict conflict;
/**
* Initialize a conflict object.
*/
CosmosConflictProperties() {
this.conflict = new Conflict();
}
/**
* Initialize a conflict object from json string.
*
* @param jsonNode the json node that represents the conflict.
*/
CosmosConflictProperties(ObjectNode jsonNode) {
this.conflict = new Conflict(jsonNode);
}
/**
* Gets the operation kind.
*
* @return the operation kind.
*/
public OperationKind getOperationKind() {
return this.conflict.getOperationKind();
}
/**
* Gets the type of the conflicting resource.
*
* @return the resource type.
*/
String getResourceType() {
return this.conflict.getResourceType();
}
Resource getResource() {
return this.conflict;
}
/**
* Gets the conflicting resource in the Azure Cosmos DB service.
*
* @param the type of the object.
* @param klass The returned type of conflicting resource.
* @return The conflicting resource.
*/
public T getItem(Class klass) {
return this.conflict.getItem(klass);
}
/**
* Gets the name of the resource.
*
* @return the name of the resource.
*/
public String getId() {
return this.conflict.getId();
}
/**
* Sets the name of the resource.
*
* @param id the name of the resource.
* @return the current instance of {@link CosmosConflictProperties}.
*/
public CosmosConflictProperties setId(String id) {
this.conflict.setId(id);
return this;
}
/**
* Gets the ID associated with the resource.
*
* @return the ID associated with the resource.
*/
String getResourceId() {
return this.conflict.getResourceId();
}
/**
* Get the last modified timestamp associated with the resource.
* This is only relevant when getting response from the server.
*
* @return the timestamp.
*/
public Instant getTimestamp() {
return this.conflict.getTimestamp();
}
/**
* Get the entity tag associated with the resource.
* This is only relevant when getting response from the server.
*
* @return the e tag.
*/
public String getETag() {
return this.conflict.getETag();
}
static List getFromV2Results(List results) {
return results.stream().map(conflict -> new CosmosConflictProperties(conflict.getPropertyBag()))
.collect(Collectors.toList());
}
}