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

org.camunda.community.rest.client.dto.PatchVariablesDto Maven / Gradle / Ivy

The newest version!
/*
 * Camunda Platform REST API
 * OpenApi Spec for Camunda Platform REST API.
 *
 * The version of the OpenAPI document: 7.21.0
 * 
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */


package org.camunda.community.rest.client.dto;

import java.util.Objects;
import java.util.Arrays;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.annotation.JsonValue;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.camunda.community.rest.client.dto.VariableValueDto;
import org.openapitools.jackson.nullable.JsonNullable;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.openapitools.jackson.nullable.JsonNullable;
import java.util.NoSuchElementException;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonTypeName;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.StringJoiner;

/**
 * PatchVariablesDto
 */
@JsonPropertyOrder({
  PatchVariablesDto.JSON_PROPERTY_MODIFICATIONS,
  PatchVariablesDto.JSON_PROPERTY_DELETIONS
})
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-06-27T13:50:23.655629899Z[Etc/UTC]")
public class PatchVariablesDto {
  public static final String JSON_PROPERTY_MODIFICATIONS = "modifications";
  private JsonNullable> modifications = JsonNullable.>undefined();

  public static final String JSON_PROPERTY_DELETIONS = "deletions";
  private JsonNullable> deletions = JsonNullable.>undefined();

  public PatchVariablesDto() {
  }

  public PatchVariablesDto modifications(Map modifications) {
    this.modifications = JsonNullable.>of(modifications);
    
    return this;
  }

  public PatchVariablesDto putModificationsItem(String key, VariableValueDto modificationsItem) {
    if (this.modifications == null || !this.modifications.isPresent()) {
      this.modifications = JsonNullable.>of(new HashMap<>());
    }
    try {
      this.modifications.get().put(key, modificationsItem);
    } catch (java.util.NoSuchElementException e) {
      // this can never happen, as we make sure above that the value is present
    }
    return this;
  }

   /**
   * A JSON object containing variable key-value pairs.
   * @return modifications
  **/
  @javax.annotation.Nullable
  @JsonIgnore

  public Map getModifications() {
        return modifications.orElse(null);
  }

  @JsonProperty(JSON_PROPERTY_MODIFICATIONS)
  @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

  public JsonNullable> getModifications_JsonNullable() {
    return modifications;
  }
  
  @JsonProperty(JSON_PROPERTY_MODIFICATIONS)
  public void setModifications_JsonNullable(JsonNullable> modifications) {
    this.modifications = modifications;
  }

  public void setModifications(Map modifications) {
    this.modifications = JsonNullable.>of(modifications);
  }


  public PatchVariablesDto deletions(List deletions) {
    this.deletions = JsonNullable.>of(deletions);
    
    return this;
  }

  public PatchVariablesDto addDeletionsItem(String deletionsItem) {
    if (this.deletions == null || !this.deletions.isPresent()) {
      this.deletions = JsonNullable.>of(new ArrayList<>());
    }
    try {
      this.deletions.get().add(deletionsItem);
    } catch (java.util.NoSuchElementException e) {
      // this can never happen, as we make sure above that the value is present
    }
    return this;
  }

   /**
   * An array of String keys of variables to be deleted.
   * @return deletions
  **/
  @javax.annotation.Nullable
  @JsonIgnore

  public List getDeletions() {
        return deletions.orElse(null);
  }

  @JsonProperty(JSON_PROPERTY_DELETIONS)
  @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

  public JsonNullable> getDeletions_JsonNullable() {
    return deletions;
  }
  
  @JsonProperty(JSON_PROPERTY_DELETIONS)
  public void setDeletions_JsonNullable(JsonNullable> deletions) {
    this.deletions = deletions;
  }

  public void setDeletions(List deletions) {
    this.deletions = JsonNullable.>of(deletions);
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    PatchVariablesDto patchVariablesDto = (PatchVariablesDto) o;
    return equalsNullable(this.modifications, patchVariablesDto.modifications) &&
        equalsNullable(this.deletions, patchVariablesDto.deletions);
  }

  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(hashCodeNullable(modifications), hashCodeNullable(deletions));
  }

  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 PatchVariablesDto {\n");
    sb.append("    modifications: ").append(toIndentedString(modifications)).append("\n");
    sb.append("    deletions: ").append(toIndentedString(deletions)).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    ");
  }

  /**
   * Convert the instance into URL query string.
   *
   * @return URL query string
   */
  public String toUrlQueryString() {
    return toUrlQueryString(null);
  }

  /**
   * Convert the instance into URL query string.
   *
   * @param prefix prefix of the query string
   * @return URL query string
   */
  public String toUrlQueryString(String prefix) {
    String suffix = "";
    String containerSuffix = "";
    String containerPrefix = "";
    if (prefix == null) {
      // style=form, explode=true, e.g. /pet?name=cat&type=manx
      prefix = "";
    } else {
      // deepObject style e.g. /pet?id[name]=cat&id[type]=manx
      prefix = prefix + "[";
      suffix = "]";
      containerSuffix = "]";
      containerPrefix = "[";
    }

    StringJoiner joiner = new StringJoiner("&");

    // add `modifications` to the URL query string
    if (getModifications() != null) {
      for (String _key : getModifications().keySet()) {
        if (getModifications().get(_key) != null) {
          joiner.add(getModifications().get(_key).toUrlQueryString(String.format("%smodifications%s%s", prefix, suffix,
              "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix))));
        }
      }
    }

    // add `deletions` to the URL query string
    if (getDeletions() != null) {
      for (int i = 0; i < getDeletions().size(); i++) {
        try {
          joiner.add(String.format("%sdeletions%s%s=%s", prefix, suffix,
              "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
              URLEncoder.encode(String.valueOf(getDeletions().get(i)), "UTF-8").replaceAll("\\+", "%20")));
        } catch (UnsupportedEncodingException e) {
          // Should never happen, UTF-8 is always supported
          throw new RuntimeException(e);
        }
      }
    }

    return joiner.toString();
  }

}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy