com.dropbox.sign.model.SignatureRequestResponseCustomFieldBase Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dropbox-sign Show documentation
Show all versions of dropbox-sign Show documentation
Use the Dropbox Sign Java SDK to connect your Java app to the service of Dropbox Sign in microseconds!
The newest version!
/*
* Dropbox Sign API
* Dropbox Sign v3 API
*
* The version of the OpenAPI document: 3.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package com.dropbox.sign.model;
import java.util.Objects;
import java.util.Map;
import java.util.HashMap;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.annotation.JsonValue;
import java.util.Arrays;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.dropbox.sign.JSON;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.dropbox.sign.ApiException;
/**
* An array of Custom Field objects containing the name and type of each custom field. * Text Field uses `SignatureRequestResponseCustomFieldText` * Checkbox Field uses `SignatureRequestResponseCustomFieldCheckbox`
*/
@JsonPropertyOrder({
SignatureRequestResponseCustomFieldBase.JSON_PROPERTY_TYPE,
SignatureRequestResponseCustomFieldBase.JSON_PROPERTY_NAME,
SignatureRequestResponseCustomFieldBase.JSON_PROPERTY_REQUIRED,
SignatureRequestResponseCustomFieldBase.JSON_PROPERTY_API_ID,
SignatureRequestResponseCustomFieldBase.JSON_PROPERTY_EDITOR
})
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0")
@JsonIgnoreProperties(
allowSetters = true, // allows the type to be set during deserialization
ignoreUnknown = true
)
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "type", visible = true)
@JsonSubTypes({
@JsonSubTypes.Type(value = SignatureRequestResponseCustomFieldCheckbox.class, name = "checkbox"),
@JsonSubTypes.Type(value = SignatureRequestResponseCustomFieldText.class, name = "text"),
})
public class SignatureRequestResponseCustomFieldBase {
public static final String JSON_PROPERTY_TYPE = "type";
private String type;
public static final String JSON_PROPERTY_NAME = "name";
private String name;
public static final String JSON_PROPERTY_REQUIRED = "required";
private Boolean required;
public static final String JSON_PROPERTY_API_ID = "api_id";
private String apiId;
public static final String JSON_PROPERTY_EDITOR = "editor";
private String editor;
public SignatureRequestResponseCustomFieldBase() {
}
/**
* Attempt to instantiate and hydrate a new instance of this class
* @param jsonData String of JSON data representing target object
*/
static public SignatureRequestResponseCustomFieldBase init(String jsonData) throws Exception {
return new ObjectMapper().readValue(jsonData, SignatureRequestResponseCustomFieldBase.class);
}
static public SignatureRequestResponseCustomFieldBase init(HashMap data) throws Exception {
return new ObjectMapper().readValue(
new ObjectMapper().writeValueAsString(data),
SignatureRequestResponseCustomFieldBase.class
);
}
public SignatureRequestResponseCustomFieldBase type(String type) {
this.type = type;
return this;
}
/**
* The type of this Custom Field. Only 'text' and 'checkbox' are currently supported.
* @return type
*/
@jakarta.annotation.Nonnull
@JsonProperty(JSON_PROPERTY_TYPE)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
public String getType() {
return type;
}
@JsonProperty(JSON_PROPERTY_TYPE)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
public void setType(String type) {
this.type = type;
}
public SignatureRequestResponseCustomFieldBase name(String name) {
this.name = name;
return this;
}
/**
* The name of the Custom Field.
* @return name
*/
@jakarta.annotation.Nonnull
@JsonProperty(JSON_PROPERTY_NAME)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
public String getName() {
return name;
}
@JsonProperty(JSON_PROPERTY_NAME)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
public void setName(String name) {
this.name = name;
}
public SignatureRequestResponseCustomFieldBase required(Boolean required) {
this.required = required;
return this;
}
/**
* A boolean value denoting if this field is required.
* @return required
*/
@jakarta.annotation.Nullable
@JsonProperty(JSON_PROPERTY_REQUIRED)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public Boolean getRequired() {
return required;
}
@JsonProperty(JSON_PROPERTY_REQUIRED)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setRequired(Boolean required) {
this.required = required;
}
public SignatureRequestResponseCustomFieldBase apiId(String apiId) {
this.apiId = apiId;
return this;
}
/**
* The unique ID for this field.
* @return apiId
*/
@jakarta.annotation.Nullable
@JsonProperty(JSON_PROPERTY_API_ID)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public String getApiId() {
return apiId;
}
@JsonProperty(JSON_PROPERTY_API_ID)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setApiId(String apiId) {
this.apiId = apiId;
}
public SignatureRequestResponseCustomFieldBase editor(String editor) {
this.editor = editor;
return this;
}
/**
* The name of the Role that is able to edit this field.
* @return editor
*/
@jakarta.annotation.Nullable
@JsonProperty(JSON_PROPERTY_EDITOR)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public String getEditor() {
return editor;
}
@JsonProperty(JSON_PROPERTY_EDITOR)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setEditor(String editor) {
this.editor = editor;
}
/**
* Return true if this SignatureRequestResponseCustomFieldBase object is equal to o.
*/
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
SignatureRequestResponseCustomFieldBase signatureRequestResponseCustomFieldBase = (SignatureRequestResponseCustomFieldBase) o;
return Objects.equals(this.type, signatureRequestResponseCustomFieldBase.type) &&
Objects.equals(this.name, signatureRequestResponseCustomFieldBase.name) &&
Objects.equals(this.required, signatureRequestResponseCustomFieldBase.required) &&
Objects.equals(this.apiId, signatureRequestResponseCustomFieldBase.apiId) &&
Objects.equals(this.editor, signatureRequestResponseCustomFieldBase.editor);
}
@Override
public int hashCode() {
return Objects.hash(type, name, required, apiId, editor);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class SignatureRequestResponseCustomFieldBase {\n");
sb.append(" type: ").append(toIndentedString(type)).append("\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" required: ").append(toIndentedString(required)).append("\n");
sb.append(" apiId: ").append(toIndentedString(apiId)).append("\n");
sb.append(" editor: ").append(toIndentedString(editor)).append("\n");
sb.append("}");
return sb.toString();
}
public Map createFormData() throws ApiException {
Map map = new HashMap<>();
boolean fileTypeFound = false;
try {
if (type != null) {
if (isFileTypeOrListOfFiles(type)) {
fileTypeFound = true;
}
if (type.getClass().equals(java.io.File.class) ||
type.getClass().equals(Integer.class) ||
type.getClass().equals(String.class) ||
type.getClass().isEnum()) {
map.put("type", type);
} else if (isListOfFile(type)) {
for(int i = 0; i< getListSize(type); i++) {
map.put("type[" + i + "]", getFromList(type, i));
}
}
else {
map.put("type", JSON.getDefault().getMapper().writeValueAsString(type));
}
}
if (name != null) {
if (isFileTypeOrListOfFiles(name)) {
fileTypeFound = true;
}
if (name.getClass().equals(java.io.File.class) ||
name.getClass().equals(Integer.class) ||
name.getClass().equals(String.class) ||
name.getClass().isEnum()) {
map.put("name", name);
} else if (isListOfFile(name)) {
for(int i = 0; i< getListSize(name); i++) {
map.put("name[" + i + "]", getFromList(name, i));
}
}
else {
map.put("name", JSON.getDefault().getMapper().writeValueAsString(name));
}
}
if (required != null) {
if (isFileTypeOrListOfFiles(required)) {
fileTypeFound = true;
}
if (required.getClass().equals(java.io.File.class) ||
required.getClass().equals(Integer.class) ||
required.getClass().equals(String.class) ||
required.getClass().isEnum()) {
map.put("required", required);
} else if (isListOfFile(required)) {
for(int i = 0; i< getListSize(required); i++) {
map.put("required[" + i + "]", getFromList(required, i));
}
}
else {
map.put("required", JSON.getDefault().getMapper().writeValueAsString(required));
}
}
if (apiId != null) {
if (isFileTypeOrListOfFiles(apiId)) {
fileTypeFound = true;
}
if (apiId.getClass().equals(java.io.File.class) ||
apiId.getClass().equals(Integer.class) ||
apiId.getClass().equals(String.class) ||
apiId.getClass().isEnum()) {
map.put("api_id", apiId);
} else if (isListOfFile(apiId)) {
for(int i = 0; i< getListSize(apiId); i++) {
map.put("api_id[" + i + "]", getFromList(apiId, i));
}
}
else {
map.put("api_id", JSON.getDefault().getMapper().writeValueAsString(apiId));
}
}
if (editor != null) {
if (isFileTypeOrListOfFiles(editor)) {
fileTypeFound = true;
}
if (editor.getClass().equals(java.io.File.class) ||
editor.getClass().equals(Integer.class) ||
editor.getClass().equals(String.class) ||
editor.getClass().isEnum()) {
map.put("editor", editor);
} else if (isListOfFile(editor)) {
for(int i = 0; i< getListSize(editor); i++) {
map.put("editor[" + i + "]", getFromList(editor, i));
}
}
else {
map.put("editor", JSON.getDefault().getMapper().writeValueAsString(editor));
}
}
} catch (Exception e) {
throw new ApiException(e);
}
return fileTypeFound ? map : new HashMap<>();
}
private boolean isFileTypeOrListOfFiles(Object obj) throws Exception {
return obj.getClass().equals(java.io.File.class) || isListOfFile(obj);
}
private boolean isListOfFile(Object obj) throws Exception {
return obj instanceof java.util.List && !isListEmpty(obj) && getFromList(obj, 0) instanceof java.io.File;
}
private boolean isListEmpty(Object obj) throws Exception {
return (boolean) Class.forName(java.util.List.class.getName()).getMethod("isEmpty").invoke(obj);
}
private Object getFromList(Object obj, int index) throws Exception {
return Class.forName(java.util.List.class.getName()).getMethod("get", int.class).invoke(obj, index);
}
private int getListSize(Object obj) throws Exception {
return (int) Class.forName(java.util.List.class.getName()).getMethod("size").invoke(obj);
}
/**
* 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 ");
}
static {
// Initialize and register the discriminator mappings.
Map> mappings = new HashMap<>();
mappings.put("checkbox", SignatureRequestResponseCustomFieldCheckbox.class);
mappings.put("text", SignatureRequestResponseCustomFieldText.class);
mappings.put("SignatureRequestResponseCustomFieldBase", SignatureRequestResponseCustomFieldBase.class);
JSON.registerDiscriminator(SignatureRequestResponseCustomFieldBase.class, "type", mappings);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy