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

com.finbourne.horizon.model.IntegrationDescription Maven / Gradle / Ivy

The newest version!
/*
 * FINBOURNE Horizon API
 *
 * 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.finbourne.horizon.model;

import java.util.Objects;
import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.reflect.TypeToken;
import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import com.finbourne.horizon.JSON;

/**
 * Response containing the description of an integration.
 */
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class IntegrationDescription {
  public static final String SERIALIZED_NAME_TYPE = "type";
  @SerializedName(SERIALIZED_NAME_TYPE)
  private String type;

  public static final String SERIALIZED_NAME_NAME = "name";
  @SerializedName(SERIALIZED_NAME_NAME)
  private String name;

  public static final String SERIALIZED_NAME_DESCRIPTION = "description";
  @SerializedName(SERIALIZED_NAME_DESCRIPTION)
  private String description;

  public static final String SERIALIZED_NAME_SUPPORTED_TRIGGER_TYPES = "supportedTriggerTypes";
  @SerializedName(SERIALIZED_NAME_SUPPORTED_TRIGGER_TYPES)
  private List supportedTriggerTypes = new ArrayList<>();

  public static final String SERIALIZED_NAME_LICENSED = "licensed";
  @SerializedName(SERIALIZED_NAME_LICENSED)
  private Boolean licensed;

  public IntegrationDescription() {
  }

  public IntegrationDescription type(String type) {
    
    this.type = type;
    return this;
  }

   /**
   * Unique identifier of the integration e.g. \"copp-clark\".
   * @return type
  **/
  @jakarta.annotation.Nonnull
  public String getType() {
    return type;
  }


  public void setType(String type) {
    this.type = type;
  }


  public IntegrationDescription name(String name) {
    
    this.name = name;
    return this;
  }

   /**
   * Readable name of the integration e.g. \"Copp Clark\".
   * @return name
  **/
  @jakarta.annotation.Nonnull
  public String getName() {
    return name;
  }


  public void setName(String name) {
    this.name = name;
  }


  public IntegrationDescription description(String description) {
    
    this.description = description;
    return this;
  }

   /**
   * Describes the purpose of the integration.
   * @return description
  **/
  @jakarta.annotation.Nonnull
  public String getDescription() {
    return description;
  }


  public void setDescription(String description) {
    this.description = description;
  }


  public IntegrationDescription supportedTriggerTypes(List supportedTriggerTypes) {
    
    this.supportedTriggerTypes = supportedTriggerTypes;
    return this;
  }

  public IntegrationDescription addSupportedTriggerTypesItem(String supportedTriggerTypesItem) {
    if (this.supportedTriggerTypes == null) {
      this.supportedTriggerTypes = new ArrayList<>();
    }
    this.supportedTriggerTypes.add(supportedTriggerTypesItem);
    return this;
  }

   /**
   * Trigger types (Time, File) the integration supports.
   * @return supportedTriggerTypes
  **/
  @jakarta.annotation.Nonnull
  public List getSupportedTriggerTypes() {
    return supportedTriggerTypes;
  }


  public void setSupportedTriggerTypes(List supportedTriggerTypes) {
    this.supportedTriggerTypes = supportedTriggerTypes;
  }


  public IntegrationDescription licensed(Boolean licensed) {
    
    this.licensed = licensed;
    return this;
  }

   /**
   * True if your domain is licensed to use this integration, otherwise false.
   * @return licensed
  **/
  @jakarta.annotation.Nonnull
  public Boolean getLicensed() {
    return licensed;
  }


  public void setLicensed(Boolean licensed) {
    this.licensed = licensed;
  }



  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    IntegrationDescription integrationDescription = (IntegrationDescription) o;
    return Objects.equals(this.type, integrationDescription.type) &&
        Objects.equals(this.name, integrationDescription.name) &&
        Objects.equals(this.description, integrationDescription.description) &&
        Objects.equals(this.supportedTriggerTypes, integrationDescription.supportedTriggerTypes) &&
        Objects.equals(this.licensed, integrationDescription.licensed);
  }

  @Override
  public int hashCode() {
    return Objects.hash(type, name, description, supportedTriggerTypes, licensed);
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class IntegrationDescription {\n");
    sb.append("    type: ").append(toIndentedString(type)).append("\n");
    sb.append("    name: ").append(toIndentedString(name)).append("\n");
    sb.append("    description: ").append(toIndentedString(description)).append("\n");
    sb.append("    supportedTriggerTypes: ").append(toIndentedString(supportedTriggerTypes)).append("\n");
    sb.append("    licensed: ").append(toIndentedString(licensed)).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("type");
    openapiFields.add("name");
    openapiFields.add("description");
    openapiFields.add("supportedTriggerTypes");
    openapiFields.add("licensed");

    // a set of required properties/fields (JSON key names)
    openapiRequiredFields = new HashSet();
    openapiRequiredFields.add("type");
    openapiRequiredFields.add("name");
    openapiRequiredFields.add("description");
    openapiRequiredFields.add("supportedTriggerTypes");
    openapiRequiredFields.add("licensed");
  }

 /**
  * Validates the JSON Element and throws an exception if issues found
  *
  * @param jsonElement JSON Element
  * @throws IOException if the JSON Element is invalid with respect to IntegrationDescription
  */
  public static void validateJsonElement(JsonElement jsonElement) throws IOException {
      if (jsonElement == null) {
        if (!IntegrationDescription.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
          throw new IllegalArgumentException(String.format("The required field(s) %s in IntegrationDescription is not found in the empty JSON string", IntegrationDescription.openapiRequiredFields.toString()));
        }
      }

      // check to make sure all required properties/fields are present in the JSON string
      for (String requiredField : IntegrationDescription.openapiRequiredFields) {
        if (jsonElement.getAsJsonObject().get(requiredField) == null) {
          throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString()));
        }
      }
        JsonObject jsonObj = jsonElement.getAsJsonObject();
      if (!jsonObj.get("type").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString()));
      }
      if (!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("description").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString()));
      }
      // ensure the required json array is present
      if (jsonObj.get("supportedTriggerTypes") == null) {
        throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`");
      } else if (!jsonObj.get("supportedTriggerTypes").isJsonArray()) {
        throw new IllegalArgumentException(String.format("Expected the field `supportedTriggerTypes` to be an array in the JSON string but got `%s`", jsonObj.get("supportedTriggerTypes").toString()));
      }
  }

  public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
    @SuppressWarnings("unchecked")
    @Override
    public  TypeAdapter create(Gson gson, TypeToken type) {
       if (!IntegrationDescription.class.isAssignableFrom(type.getRawType())) {
         return null; // this class only serializes 'IntegrationDescription' and its subtypes
       }
       final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
       final TypeAdapter thisAdapter
                        = gson.getDelegateAdapter(this, TypeToken.get(IntegrationDescription.class));

       return (TypeAdapter) new TypeAdapter() {
           @Override
           public void write(JsonWriter out, IntegrationDescription value) throws IOException {
             JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
             elementAdapter.write(out, obj);
           }

           @Override
           public IntegrationDescription read(JsonReader in) throws IOException {
             JsonElement jsonElement = elementAdapter.read(in);
             validateJsonElement(jsonElement);
             return thisAdapter.fromJsonTree(jsonElement);
           }

       }.nullSafe();
    }
  }

 /**
  * Create an instance of IntegrationDescription given an JSON string
  *
  * @param jsonString JSON string
  * @return An instance of IntegrationDescription
  * @throws IOException if the JSON string is invalid with respect to IntegrationDescription
  */
  public static IntegrationDescription fromJson(String jsonString) throws IOException {
    return JSON.getGson().fromJson(jsonString, IntegrationDescription.class);
  }

 /**
  * Convert an instance of IntegrationDescription to an JSON string
  *
  * @return JSON string
  */
  public String toJson() {
    return JSON.getGson().toJson(this);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy