io.tiledb.cloud.rest_api.model.User Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tiledb-cloud-java Show documentation
Show all versions of tiledb-cloud-java Show documentation
The Java client for the TileDB Cloud Service
The newest version!
/*
* TileDB Storage Platform API
* TileDB Storage Platform REST API
*
* The version of the OpenAPI document: 2.2.19
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package io.tiledb.cloud.rest_api.model;
import java.util.Objects;
import java.util.Arrays;
import com.google.gson.TypeAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import io.tiledb.cloud.rest_api.JSON;
import org.openapitools.jackson.nullable.JsonNullable;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.reflect.TypeToken;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
/**
* User
*/
@ApiModel(description = "User")
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2023-10-02T12:25:58.319138+03:00[Europe/Athens]")
public class User {
public static final String SERIALIZED_NAME_ID = "id";
@SerializedName(SERIALIZED_NAME_ID)
private String id;
public static final String SERIALIZED_NAME_USERNAME = "username";
@SerializedName(SERIALIZED_NAME_USERNAME)
private String username;
public static final String SERIALIZED_NAME_PASSWORD = "password";
@SerializedName(SERIALIZED_NAME_PASSWORD)
private String password;
public static final String SERIALIZED_NAME_NAME = "name";
@SerializedName(SERIALIZED_NAME_NAME)
private String name;
public static final String SERIALIZED_NAME_EMAIL = "email";
@SerializedName(SERIALIZED_NAME_EMAIL)
private String email;
public static final String SERIALIZED_NAME_IS_VALID_EMAIL = "is_valid_email";
@SerializedName(SERIALIZED_NAME_IS_VALID_EMAIL)
private Boolean isValidEmail;
public static final String SERIALIZED_NAME_STRIPE_CONNECT = "stripe_connect";
@SerializedName(SERIALIZED_NAME_STRIPE_CONNECT)
private Boolean stripeConnect;
public static final String SERIALIZED_NAME_COMPANY = "company";
@SerializedName(SERIALIZED_NAME_COMPANY)
private String company;
public static final String SERIALIZED_NAME_LOGO = "logo";
@SerializedName(SERIALIZED_NAME_LOGO)
private String logo;
public static final String SERIALIZED_NAME_TIMEZONE = "timezone";
@SerializedName(SERIALIZED_NAME_TIMEZONE)
private String timezone;
public static final String SERIALIZED_NAME_ORGANIZATIONS = "organizations";
@SerializedName(SERIALIZED_NAME_ORGANIZATIONS)
private List organizations = null;
public static final String SERIALIZED_NAME_ALLOWED_ACTIONS = "allowed_actions";
@SerializedName(SERIALIZED_NAME_ALLOWED_ACTIONS)
private List allowedActions = null;
public static final String SERIALIZED_NAME_ENABLED_FEATURES = "enabled_features";
@SerializedName(SERIALIZED_NAME_ENABLED_FEATURES)
private List enabledFeatures = null;
public static final String SERIALIZED_NAME_UNPAID_SUBSCRIPTION = "unpaid_subscription";
@SerializedName(SERIALIZED_NAME_UNPAID_SUBSCRIPTION)
private Boolean unpaidSubscription;
public static final String SERIALIZED_NAME_DEFAULT_S3_PATH = "default_s3_path";
@SerializedName(SERIALIZED_NAME_DEFAULT_S3_PATH)
private String defaultS3Path;
public static final String SERIALIZED_NAME_DEFAULT_S3_PATH_CREDENTIALS_NAME = "default_s3_path_credentials_name";
@SerializedName(SERIALIZED_NAME_DEFAULT_S3_PATH_CREDENTIALS_NAME)
private Object defaultS3PathCredentialsName;
public static final String SERIALIZED_NAME_ASSET_LOCATIONS = "asset_locations";
@SerializedName(SERIALIZED_NAME_ASSET_LOCATIONS)
private AssetLocations assetLocations;
public static final String SERIALIZED_NAME_DEFAULT_NAMESPACE_CHARGED = "default_namespace_charged";
@SerializedName(SERIALIZED_NAME_DEFAULT_NAMESPACE_CHARGED)
private String defaultNamespaceCharged;
public User() {
}
public User(
Boolean isValidEmail,
Boolean stripeConnect,
List organizations,
List enabledFeatures,
Boolean unpaidSubscription
) {
this();
this.isValidEmail = isValidEmail;
this.stripeConnect = stripeConnect;
this.organizations = organizations;
this.enabledFeatures = enabledFeatures;
this.unpaidSubscription = unpaidSubscription;
}
public User id(String id) {
this.id = id;
return this;
}
/**
* unique ID of user
* @return id
**/
@javax.annotation.Nullable
@ApiModelProperty(example = "00000000-0000-0000-0000-000000000000", value = "unique ID of user")
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public User username(String username) {
this.username = username;
return this;
}
/**
* username must be unique
* @return username
**/
@javax.annotation.Nonnull
@ApiModelProperty(example = "username", required = true, value = "username must be unique")
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public User password(String password) {
this.password = password;
return this;
}
/**
* password
* @return password
**/
@javax.annotation.Nullable
@ApiModelProperty(example = "password", value = "password")
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public User name(String name) {
this.name = name;
return this;
}
/**
* the user's full, real name
* @return name
**/
@javax.annotation.Nullable
@ApiModelProperty(example = "Jane Doe", value = "the user's full, real name")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public User email(String email) {
this.email = email;
return this;
}
/**
* the user's email
* @return email
**/
@javax.annotation.Nullable
@ApiModelProperty(example = "[email protected]", value = "the user's email")
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
/**
* user's email is validated to be correct
* @return isValidEmail
**/
@javax.annotation.Nullable
@ApiModelProperty(example = "false", value = "user's email is validated to be correct")
public Boolean getIsValidEmail() {
return isValidEmail;
}
/**
* Denotes that the user is able to apply pricing to arrays by means of Stripe Connect
* @return stripeConnect
**/
@javax.annotation.Nullable
@ApiModelProperty(example = "false", value = "Denotes that the user is able to apply pricing to arrays by means of Stripe Connect")
public Boolean getStripeConnect() {
return stripeConnect;
}
public User company(String company) {
this.company = company;
return this;
}
/**
* the user's company
* @return company
**/
@javax.annotation.Nullable
@ApiModelProperty(example = "TileDB", value = "the user's company")
public String getCompany() {
return company;
}
public void setCompany(String company) {
this.company = company;
}
public User logo(String logo) {
this.logo = logo;
return this;
}
/**
* the user's logo
* @return logo
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "the user's logo")
public String getLogo() {
return logo;
}
public void setLogo(String logo) {
this.logo = logo;
}
public User timezone(String timezone) {
this.timezone = timezone;
return this;
}
/**
* Get timezone
* @return timezone
**/
@javax.annotation.Nullable
@ApiModelProperty(example = "Europe/Athens", value = "")
public String getTimezone() {
return timezone;
}
public void setTimezone(String timezone) {
this.timezone = timezone;
}
/**
* Array of organizations a user is part of and their roles
* @return organizations
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "Array of organizations a user is part of and their roles")
public List getOrganizations() {
return organizations;
}
public User allowedActions(List allowedActions) {
this.allowedActions = allowedActions;
return this;
}
public User addAllowedActionsItem(NamespaceActions allowedActionsItem) {
if (this.allowedActions == null) {
this.allowedActions = new ArrayList<>();
}
this.allowedActions.add(allowedActionsItem);
return this;
}
/**
* list of actions user is allowed to do on this organization
* @return allowedActions
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "list of actions user is allowed to do on this organization")
public List getAllowedActions() {
return allowedActions;
}
public void setAllowedActions(List allowedActions) {
this.allowedActions = allowedActions;
}
/**
* List of extra/optional/beta features to enable for namespace
* @return enabledFeatures
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "List of extra/optional/beta features to enable for namespace")
public List getEnabledFeatures() {
return enabledFeatures;
}
/**
* A notice that the user has an unpaid subscription
* @return unpaidSubscription
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "A notice that the user has an unpaid subscription")
public Boolean getUnpaidSubscription() {
return unpaidSubscription;
}
public User defaultS3Path(String defaultS3Path) {
this.defaultS3Path = defaultS3Path;
return this;
}
/**
* The default location to store newly-created notebooks and other assets like UDFs. The name `default_s3_path` is a legacy holdover; it may refer to any supported storage location.
* @return defaultS3Path
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "The default location to store newly-created notebooks and other assets like UDFs. The name `default_s3_path` is a legacy holdover; it may refer to any supported storage location. ")
public String getDefaultS3Path() {
return defaultS3Path;
}
public void setDefaultS3Path(String defaultS3Path) {
this.defaultS3Path = defaultS3Path;
}
public User defaultS3PathCredentialsName(Object defaultS3PathCredentialsName) {
this.defaultS3PathCredentialsName = defaultS3PathCredentialsName;
return this;
}
/**
* The name of the credentials used to create and access files in the `default_s3_path`, if needed.
* @return defaultS3PathCredentialsName
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "The name of the credentials used to create and access files in the `default_s3_path`, if needed. ")
public Object getDefaultS3PathCredentialsName() {
return defaultS3PathCredentialsName;
}
public void setDefaultS3PathCredentialsName(Object defaultS3PathCredentialsName) {
this.defaultS3PathCredentialsName = defaultS3PathCredentialsName;
}
public User assetLocations(AssetLocations assetLocations) {
this.assetLocations = assetLocations;
return this;
}
/**
* Get assetLocations
* @return assetLocations
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")
public AssetLocations getAssetLocations() {
return assetLocations;
}
public void setAssetLocations(AssetLocations assetLocations) {
this.assetLocations = assetLocations;
}
public User defaultNamespaceCharged(String defaultNamespaceCharged) {
this.defaultNamespaceCharged = defaultNamespaceCharged;
return this;
}
/**
* Override the default namespace charged for actions when no namespace is specified
* @return defaultNamespaceCharged
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "Override the default namespace charged for actions when no namespace is specified")
public String getDefaultNamespaceCharged() {
return defaultNamespaceCharged;
}
public void setDefaultNamespaceCharged(String defaultNamespaceCharged) {
this.defaultNamespaceCharged = defaultNamespaceCharged;
}
/**
* A container for additional, undeclared properties.
* This is a holder for any undeclared properties as specified with
* the 'additionalProperties' keyword in the OAS document.
*/
private Map additionalProperties;
/**
* Set the additional (undeclared) property with the specified name and value.
* If the property does not already exist, create it otherwise replace it.
*/
public User putAdditionalProperty(String key, Object value) {
if (this.additionalProperties == null) {
this.additionalProperties = new HashMap();
}
this.additionalProperties.put(key, value);
return this;
}
/**
* Return the additional (undeclared) property.
*/
public Map getAdditionalProperties() {
return additionalProperties;
}
/**
* Return the additional (undeclared) property with the specified name.
*/
public Object getAdditionalProperty(String key) {
if (this.additionalProperties == null) {
return null;
}
return this.additionalProperties.get(key);
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
User user = (User) o;
return Objects.equals(this.id, user.id) &&
Objects.equals(this.username, user.username) &&
Objects.equals(this.password, user.password) &&
Objects.equals(this.name, user.name) &&
Objects.equals(this.email, user.email) &&
Objects.equals(this.isValidEmail, user.isValidEmail) &&
Objects.equals(this.stripeConnect, user.stripeConnect) &&
Objects.equals(this.company, user.company) &&
Objects.equals(this.logo, user.logo) &&
Objects.equals(this.timezone, user.timezone) &&
Objects.equals(this.organizations, user.organizations) &&
Objects.equals(this.allowedActions, user.allowedActions) &&
Objects.equals(this.enabledFeatures, user.enabledFeatures) &&
Objects.equals(this.unpaidSubscription, user.unpaidSubscription) &&
Objects.equals(this.defaultS3Path, user.defaultS3Path) &&
Objects.equals(this.defaultS3PathCredentialsName, user.defaultS3PathCredentialsName) &&
Objects.equals(this.assetLocations, user.assetLocations) &&
Objects.equals(this.defaultNamespaceCharged, user.defaultNamespaceCharged)&&
Objects.equals(this.additionalProperties, user.additionalProperties);
}
private static boolean equalsNullable(JsonNullable a, JsonNullable b) {
return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get()));
}
@Override
public int hashCode() {
return Objects.hash(id, username, password, name, email, isValidEmail, stripeConnect, company, logo, timezone, organizations, allowedActions, enabledFeatures, unpaidSubscription, defaultS3Path, defaultS3PathCredentialsName, assetLocations, defaultNamespaceCharged, additionalProperties);
}
private static int hashCodeNullable(JsonNullable a) {
if (a == null) {
return 1;
}
return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class User {\n");
sb.append(" id: ").append(toIndentedString(id)).append("\n");
sb.append(" username: ").append(toIndentedString(username)).append("\n");
sb.append(" password: ").append(toIndentedString(password)).append("\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" email: ").append(toIndentedString(email)).append("\n");
sb.append(" isValidEmail: ").append(toIndentedString(isValidEmail)).append("\n");
sb.append(" stripeConnect: ").append(toIndentedString(stripeConnect)).append("\n");
sb.append(" company: ").append(toIndentedString(company)).append("\n");
sb.append(" logo: ").append(toIndentedString(logo)).append("\n");
sb.append(" timezone: ").append(toIndentedString(timezone)).append("\n");
sb.append(" organizations: ").append(toIndentedString(organizations)).append("\n");
sb.append(" allowedActions: ").append(toIndentedString(allowedActions)).append("\n");
sb.append(" enabledFeatures: ").append(toIndentedString(enabledFeatures)).append("\n");
sb.append(" unpaidSubscription: ").append(toIndentedString(unpaidSubscription)).append("\n");
sb.append(" defaultS3Path: ").append(toIndentedString(defaultS3Path)).append("\n");
sb.append(" defaultS3PathCredentialsName: ").append(toIndentedString(defaultS3PathCredentialsName)).append("\n");
sb.append(" assetLocations: ").append(toIndentedString(assetLocations)).append("\n");
sb.append(" defaultNamespaceCharged: ").append(toIndentedString(defaultNamespaceCharged)).append("\n");
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
public static HashSet openapiFields;
public static HashSet openapiRequiredFields;
static {
// a set of all properties/fields (JSON key names)
openapiFields = new HashSet();
openapiFields.add("id");
openapiFields.add("username");
openapiFields.add("password");
openapiFields.add("name");
openapiFields.add("email");
openapiFields.add("is_valid_email");
openapiFields.add("stripe_connect");
openapiFields.add("company");
openapiFields.add("logo");
openapiFields.add("timezone");
openapiFields.add("organizations");
openapiFields.add("allowed_actions");
openapiFields.add("enabled_features");
openapiFields.add("unpaid_subscription");
openapiFields.add("default_s3_path");
openapiFields.add("default_s3_path_credentials_name");
openapiFields.add("asset_locations");
openapiFields.add("default_namespace_charged");
// a set of required properties/fields (JSON key names)
openapiRequiredFields = new HashSet();
openapiRequiredFields.add("username");
}
/**
* Validates the JSON Object and throws an exception if issues found
*
* @param jsonObj JSON Object
* @throws IOException if the JSON Object is invalid with respect to User
*/
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
if (jsonObj == null) {
if (User.openapiRequiredFields.isEmpty()) {
return;
} else { // has required fields
throw new IllegalArgumentException(String.format("The required field(s) %s in User is not found in the empty JSON string", User.openapiRequiredFields.toString()));
}
}
// check to make sure all required properties/fields are present in the JSON string
for (String requiredField : User.openapiRequiredFields) {
if (jsonObj.get(requiredField) == null) {
throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString()));
}
}
if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) && !jsonObj.get("id").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString()));
}
if ((jsonObj.get("username") != null && !jsonObj.get("username").isJsonNull()) && !jsonObj.get("username").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `username` to be a primitive type in the JSON string but got `%s`", jsonObj.get("username").toString()));
}
if ((jsonObj.get("password") != null && !jsonObj.get("password").isJsonNull()) && !jsonObj.get("password").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `password` to be a primitive type in the JSON string but got `%s`", jsonObj.get("password").toString()));
}
if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString()));
}
if ((jsonObj.get("email") != null && !jsonObj.get("email").isJsonNull()) && !jsonObj.get("email").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `email` to be a primitive type in the JSON string but got `%s`", jsonObj.get("email").toString()));
}
if ((jsonObj.get("company") != null && !jsonObj.get("company").isJsonNull()) && !jsonObj.get("company").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `company` to be a primitive type in the JSON string but got `%s`", jsonObj.get("company").toString()));
}
if ((jsonObj.get("logo") != null && !jsonObj.get("logo").isJsonNull()) && !jsonObj.get("logo").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `logo` to be a primitive type in the JSON string but got `%s`", jsonObj.get("logo").toString()));
}
if ((jsonObj.get("timezone") != null && !jsonObj.get("timezone").isJsonNull()) && !jsonObj.get("timezone").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `timezone` to be a primitive type in the JSON string but got `%s`", jsonObj.get("timezone").toString()));
}
JsonArray jsonArrayorganizations = jsonObj.getAsJsonArray("organizations");
if (jsonArrayorganizations != null) {
// ensure the json data is an array
if (!jsonObj.get("organizations").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `organizations` to be an array in the JSON string but got `%s`", jsonObj.get("organizations").toString()));
}
// validate the optional field `organizations` (array)
for (int i = 0; i < jsonArrayorganizations.size(); i++) {
OrganizationUser.validateJsonObject(jsonArrayorganizations.get(i).getAsJsonObject());
};
}
// ensure the json data is an array
if ((jsonObj.get("allowed_actions") != null && !jsonObj.get("allowed_actions").isJsonNull()) && !jsonObj.get("allowed_actions").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `allowed_actions` to be an array in the JSON string but got `%s`", jsonObj.get("allowed_actions").toString()));
}
// ensure the json data is an array
if ((jsonObj.get("enabled_features") != null && !jsonObj.get("enabled_features").isJsonNull()) && !jsonObj.get("enabled_features").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `enabled_features` to be an array in the JSON string but got `%s`", jsonObj.get("enabled_features").toString()));
}
if ((jsonObj.get("default_s3_path") != null && !jsonObj.get("default_s3_path").isJsonNull()) && !jsonObj.get("default_s3_path").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `default_s3_path` to be a primitive type in the JSON string but got `%s`", jsonObj.get("default_s3_path").toString()));
}
// validate the optional field `asset_locations`
if (jsonObj.get("asset_locations") != null && !jsonObj.get("asset_locations").isJsonNull()) {
AssetLocations.validateJsonObject(jsonObj.getAsJsonObject("asset_locations"));
}
if ((jsonObj.get("default_namespace_charged") != null && !jsonObj.get("default_namespace_charged").isJsonNull()) && !jsonObj.get("default_namespace_charged").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `default_namespace_charged` to be a primitive type in the JSON string but got `%s`", jsonObj.get("default_namespace_charged").toString()));
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!User.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'User' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter
= gson.getDelegateAdapter(this, TypeToken.get(User.class));
return (TypeAdapter) new TypeAdapter() {
@Override
public void write(JsonWriter out, User value) throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
obj.remove("additionalProperties");
// serialize additonal properties
if (value.getAdditionalProperties() != null) {
for (Map.Entry entry : value.getAdditionalProperties().entrySet()) {
if (entry.getValue() instanceof String)
obj.addProperty(entry.getKey(), (String) entry.getValue());
else if (entry.getValue() instanceof Number)
obj.addProperty(entry.getKey(), (Number) entry.getValue());
else if (entry.getValue() instanceof Boolean)
obj.addProperty(entry.getKey(), (Boolean) entry.getValue());
else if (entry.getValue() instanceof Character)
obj.addProperty(entry.getKey(), (Character) entry.getValue());
else {
obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject());
}
}
}
elementAdapter.write(out, obj);
}
@Override
public User read(JsonReader in) throws IOException {
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
validateJsonObject(jsonObj);
// store additional fields in the deserialized instance
User instance = thisAdapter.fromJsonTree(jsonObj);
for (Map.Entry entry : jsonObj.entrySet()) {
if (!openapiFields.contains(entry.getKey())) {
if (entry.getValue().isJsonPrimitive()) { // primitive type
if (entry.getValue().getAsJsonPrimitive().isString())
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString());
else if (entry.getValue().getAsJsonPrimitive().isNumber())
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber());
else if (entry.getValue().getAsJsonPrimitive().isBoolean())
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean());
else
throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString()));
} else { // non-primitive type
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class));
}
}
}
return instance;
}
}.nullSafe();
}
}
/**
* Create an instance of User given an JSON string
*
* @param jsonString JSON string
* @return An instance of User
* @throws IOException if the JSON string is invalid with respect to User
*/
public static User fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, User.class);
}
/**
* Convert an instance of User to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy