All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.azure.cosmos.implementation.SpatialIndex Maven / Gradle / Ivy

Go to download

This Package contains Microsoft Azure Cosmos SDK (with Reactive Extension Reactor support) for Azure Cosmos DB SQL API

There is a newer version: 4.60.0
Show newest version
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.cosmos.implementation;

import com.azure.cosmos.implementation.apachecommons.lang.StringUtils;
import com.fasterxml.jackson.databind.node.ObjectNode;

/**
 * Represents a spatial index in the Azure Cosmos DB database service.
 */
public final class SpatialIndex extends Index {

    /**
     * Initializes a new instance of the SpatialIndex class.
     * 

* Here is an example to instantiate SpatialIndex class passing in the DataType *

{@code SpatialIndex spatialIndex = new SpatialIndex(DataType.POINT);}
* * @param dataType specifies the target data type for the index path specification. */ SpatialIndex(DataType dataType) { super(IndexKind.SPATIAL); this.setDataType(dataType); } /** * Initializes a new instance of the SpatialIndex class. * * @param jsonString the json string that represents the index. */ public SpatialIndex(String jsonString) { super(jsonString, IndexKind.SPATIAL); if (this.getDataType() == null) { throw new IllegalArgumentException("The jsonString doesn't contain a valid 'dataType'."); } } /** * Initializes a new instance of the SpatialIndex class. * * @param objectNode the object node that represents the index. */ SpatialIndex(ObjectNode objectNode) { super(objectNode, IndexKind.SPATIAL); if (this.getDataType() == null) { throw new IllegalArgumentException("The jsonString doesn't contain a valid 'dataType'."); } } /** * Gets data type. * * @return the data type. */ public DataType getDataType() { DataType result = null; try { result = DataType.valueOf(StringUtils.upperCase(super.getString(Constants.Properties.DATA_TYPE))); } catch (IllegalArgumentException e) { super.getLogger().warn("INVALID index dataType value {}.", super.getString(Constants.Properties.DATA_TYPE)); } return result; } /** * Sets data type. * * @param dataType the data type. * @return the SpatialIndex. */ public SpatialIndex setDataType(DataType dataType) { super.set(Constants.Properties.DATA_TYPE, dataType.toString()); return this; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy