io.github.thunderz99.cosmos.CosmosDocument Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-cosmos Show documentation
Show all versions of java-cosmos Show documentation
A lightweight Azure CosmosDB client for Java
package io.github.thunderz99.cosmos;
import java.util.Map;
import io.github.thunderz99.cosmos.util.JsonUtil;
/**
* Represent a CosmosDB document. Has a JSONObject inside.
*
* Having toObject and toJson util method to convert to Class or String
* conveniently.
*/
public class CosmosDocument {
/**
* used for sdk v4
*/
Map mapObj;
public CosmosDocument(Map mapObj) {
this.mapObj = mapObj;
}
public T toObject(Class classOfT) {
return mapObj == null ? null
: JsonUtil.fromMap(mapObj, classOfT);
}
public String toJson() {
return mapObj == null ? null
: JsonUtil.toJson(mapObj);
}
public Map toMap() {
return mapObj == null ? null
: mapObj;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy