Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package com.azure.cosmos.implementation;

import com.azure.cosmos.BridgeInternal;
import com.azure.cosmos.models.DatabaseAccountLocation;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.azure.cosmos.implementation.apachecommons.lang.ObjectUtils;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,30 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.cosmos.models;
package com.azure.cosmos.implementation;

import com.azure.cosmos.implementation.Constants;
import com.azure.cosmos.implementation.JsonSerializable;
import com.fasterxml.jackson.databind.node.ObjectNode;

import static com.azure.cosmos.BridgeInternal.setProperty;

/**
* Represents the location of a database account in the Azure Cosmos DB database service.
*/
public final class DatabaseAccountLocation {
private JsonSerializable jsonSerializable;

public final class DatabaseAccountLocation extends JsonSerializable {
/**
* Constructor.
*
* @param objectNode the {@link ObjectNode} that represent the
* {@link JsonSerializable}
*/
DatabaseAccountLocation(ObjectNode objectNode) {
this.jsonSerializable = new JsonSerializable(objectNode);
public DatabaseAccountLocation(ObjectNode objectNode) {
super(objectNode);
}

/**
* DEFAULT Constructor. Creates a new instance of the
* DatabaseAccountLocation object.
*/
public DatabaseAccountLocation() {
this.jsonSerializable = new JsonSerializable();
super();
}

/**
Expand All @@ -40,7 +34,7 @@ public DatabaseAccountLocation() {
* @param jsonString the JSON string that represents the DatabaseAccountLocation object.
*/
public DatabaseAccountLocation(String jsonString) {
this.jsonSerializable = new JsonSerializable(jsonString);
super(jsonString);
}

/**
Expand All @@ -49,17 +43,16 @@ public DatabaseAccountLocation(String jsonString) {
* @return the name of the database account location.
*/
public String getName() {
return this.jsonSerializable.getString(Constants.Properties.Name);
return super.getString(Constants.Properties.Name);
}

/**
* Sets the name of the database account location.
*
* @param name the name of the database account location.
*/
void setName(String name) {

setProperty(this.jsonSerializable, Constants.Properties.Name, name);
public void setName(String name) {
super.set( Constants.Properties.Name, name);
}

/**
Expand All @@ -68,21 +61,15 @@ void setName(String name) {
* @return the endpoint of the database account location.
*/
public String getEndpoint() {
return this.jsonSerializable.getString(Constants.Properties.DATABASE_ACCOUNT_ENDPOINT);
return super.getString(Constants.Properties.DATABASE_ACCOUNT_ENDPOINT);
}

/**
* Sets the endpoint (the URI) of the database account location.
*
* @param endpoint the endpoint of the database account location.
*/
void setEndpoint(String endpoint) {
setProperty(this.jsonSerializable, Constants.Properties.DATABASE_ACCOUNT_ENDPOINT, endpoint);
public void setEndpoint(String endpoint) {
super.set(Constants.Properties.DATABASE_ACCOUNT_ENDPOINT, endpoint);
}

void populatePropertyBag() {
this.jsonSerializable.populatePropertyBag();
}

JsonSerializable getJsonSerializable() { return this.jsonSerializable; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import com.azure.cosmos.models.CompositePath;
import com.azure.cosmos.models.ConflictResolutionPolicy;
import com.azure.cosmos.models.DatabaseAccountLocation;
import com.azure.cosmos.models.ExcludedPath;
import com.azure.cosmos.models.IncludedPath;
import com.azure.cosmos.models.Index;
Expand Down Expand Up @@ -686,7 +685,6 @@ public ObjectNode getPropertyBag() {
<T> boolean containsJsonSerializable(Class<T> c) {
return CompositePath.class.equals(c)
|| ConflictResolutionPolicy.class.equals(c)
|| DatabaseAccountLocation.class.equals(c)
|| ExcludedPath.class.equals(c)
|| IncludedPath.class.equals(c)
|| IndexingPolicy.class.equals(c)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.azure.cosmos.implementation.apachecommons.collections.map.CaseInsensitiveMap;
import com.azure.cosmos.implementation.apachecommons.collections.map.UnmodifiableMap;
import com.azure.cosmos.implementation.DatabaseAccount;
import com.azure.cosmos.models.DatabaseAccountLocation;
import com.azure.cosmos.implementation.DatabaseAccountLocation;
import com.azure.cosmos.implementation.Configs;
import com.azure.cosmos.implementation.ResourceType;
import com.azure.cosmos.implementation.RxDocumentServiceRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.azure.cosmos.implementation.CosmosResourceType;
import com.azure.cosmos.implementation.Database;
import com.azure.cosmos.implementation.DatabaseAccount;
import com.azure.cosmos.implementation.DatabaseAccountLocation;
import com.azure.cosmos.implementation.Document;
import com.azure.cosmos.implementation.DocumentCollection;
import com.azure.cosmos.implementation.HttpConstants;
Expand Down Expand Up @@ -559,8 +560,6 @@ public static <T> void populatePropertyBag(T t) {
((CompositePath) t).populatePropertyBag();
} else if (t instanceof ConflictResolutionPolicy) {
((ConflictResolutionPolicy) t).populatePropertyBag();
} else if (t instanceof DatabaseAccountLocation) {
((DatabaseAccountLocation) t).populatePropertyBag();
} else if (t instanceof ExcludedPath) {
((ExcludedPath) t).populatePropertyBag();
} else if (t instanceof IncludedPath) {
Expand Down Expand Up @@ -594,8 +593,6 @@ public static <T> JsonSerializable getJsonSerializable(T t) {
return ((CompositePath) t).getJsonSerializable();
} else if (t instanceof ConflictResolutionPolicy) {
return ((ConflictResolutionPolicy) t).getJsonSerializable();
} else if (t instanceof DatabaseAccountLocation) {
return ((DatabaseAccountLocation) t).getJsonSerializable();
} else if (t instanceof ExcludedPath) {
return ((ExcludedPath) t).getJsonSerializable();
} else if (t instanceof IncludedPath) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.azure.cosmos.implementation.LifeCycleUtils;
import com.azure.cosmos.implementation.apachecommons.collections.list.UnmodifiableList;
import com.azure.cosmos.implementation.DatabaseAccount;
import com.azure.cosmos.models.DatabaseAccountLocation;
import com.azure.cosmos.implementation.DatabaseAccountLocation;
import com.azure.cosmos.implementation.Configs;
import com.azure.cosmos.implementation.DatabaseAccountManagerInternal;
import com.azure.cosmos.implementation.GlobalEndpointManager;
Expand Down Expand Up @@ -39,7 +39,6 @@
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

import static com.azure.cosmos.models.ModelBridgeUtils.createDatabaseAccountLocation;
import static org.assertj.core.api.Assertions.assertThat;

/**
Expand Down Expand Up @@ -437,4 +436,12 @@ private static URI createUrl(String url) {
throw new IllegalArgumentException(e);
}
}

private static DatabaseAccountLocation createDatabaseAccountLocation(String name, String endpoint) {
DatabaseAccountLocation dal = new DatabaseAccountLocation();
dal.setName(name);
dal.setEndpoint(endpoint);

return dal;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package com.azure.cosmos.models;

import com.azure.cosmos.implementation.DatabaseAccount;
import com.azure.cosmos.implementation.DatabaseAccountLocation;

import java.util.List;

Expand All @@ -28,14 +29,6 @@ public static DatabaseAccount createDatabaseAccount(List<DatabaseAccountLocation
return dbAccount;
}

public static DatabaseAccountLocation createDatabaseAccountLocation(String name, String endpoint) {
DatabaseAccountLocation dal = new DatabaseAccountLocation();
dal.setName(name);
dal.setEndpoint(endpoint);

return dal;
}

public static ConflictResolutionPolicy setMode(ConflictResolutionPolicy policy, ConflictResolutionMode mode) {
policy.setMode(mode);
return policy;
Expand Down