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

com.influxdb.client.domain.TemplateSummaryDiffNotificationEndpoints Maven / Gradle / Ivy

/*
 * InfluxDB OSS API Service
 * The InfluxDB v2 API provides a programmatic interface for all interactions with InfluxDB. Access the InfluxDB API using the `/api/v2/` endpoint. 
 *
 * OpenAPI spec version: 2.0.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 com.influxdb.client.domain;

import java.util.Objects;
import java.util.Arrays;
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.JsonSerializationContext;
import com.google.gson.JsonSerializer;
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 com.influxdb.client.domain.NotificationEndpointDiscriminator;
import com.influxdb.client.domain.TemplateKind;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

/**
 * TemplateSummaryDiffNotificationEndpoints
 */

public class TemplateSummaryDiffNotificationEndpoints {
  public static final String SERIALIZED_NAME_KIND = "kind";
  @SerializedName(SERIALIZED_NAME_KIND)
  private TemplateKind kind = null;

  public static final String SERIALIZED_NAME_STATE_STATUS = "stateStatus";
  @SerializedName(SERIALIZED_NAME_STATE_STATUS)
  private String stateStatus;

  public static final String SERIALIZED_NAME_ID = "id";
  @SerializedName(SERIALIZED_NAME_ID)
  private String id;

  public static final String SERIALIZED_NAME_TEMPLATE_META_NAME = "templateMetaName";
  @SerializedName(SERIALIZED_NAME_TEMPLATE_META_NAME)
  private String templateMetaName;

  public static final String SERIALIZED_NAME_NEW = "new";
  @SerializedName(SERIALIZED_NAME_NEW)
  @JsonAdapter(TemplateSummary_diff_notificationEndpointsNewAdapter.class)
  private NotificationEndpointDiscriminator _new = null;

  public static final String SERIALIZED_NAME_OLD = "old";
  @SerializedName(SERIALIZED_NAME_OLD)
  @JsonAdapter(TemplateSummary_diff_notificationEndpointsOldAdapter.class)
  private NotificationEndpointDiscriminator old = null;

  public TemplateSummaryDiffNotificationEndpoints kind(TemplateKind kind) {
    this.kind = kind;
    return this;
  }

   /**
   * Get kind
   * @return kind
  **/
  public TemplateKind getKind() {
    return kind;
  }

  public void setKind(TemplateKind kind) {
    this.kind = kind;
  }

  public TemplateSummaryDiffNotificationEndpoints stateStatus(String stateStatus) {
    this.stateStatus = stateStatus;
    return this;
  }

   /**
   * Get stateStatus
   * @return stateStatus
  **/
  public String getStateStatus() {
    return stateStatus;
  }

  public void setStateStatus(String stateStatus) {
    this.stateStatus = stateStatus;
  }

  public TemplateSummaryDiffNotificationEndpoints id(String id) {
    this.id = id;
    return this;
  }

   /**
   * Get id
   * @return id
  **/
  public String getId() {
    return id;
  }

  public void setId(String id) {
    this.id = id;
  }

  public TemplateSummaryDiffNotificationEndpoints templateMetaName(String templateMetaName) {
    this.templateMetaName = templateMetaName;
    return this;
  }

   /**
   * Get templateMetaName
   * @return templateMetaName
  **/
  public String getTemplateMetaName() {
    return templateMetaName;
  }

  public void setTemplateMetaName(String templateMetaName) {
    this.templateMetaName = templateMetaName;
  }

  public TemplateSummaryDiffNotificationEndpoints _new(NotificationEndpointDiscriminator _new) {
    this._new = _new;
    return this;
  }

   /**
   * Get _new
   * @return _new
  **/
  public NotificationEndpointDiscriminator getNew() {
    return _new;
  }

  public void setNew(NotificationEndpointDiscriminator _new) {
    this._new = _new;
  }

  public TemplateSummaryDiffNotificationEndpoints old(NotificationEndpointDiscriminator old) {
    this.old = old;
    return this;
  }

   /**
   * Get old
   * @return old
  **/
  public NotificationEndpointDiscriminator getOld() {
    return old;
  }

  public void setOld(NotificationEndpointDiscriminator old) {
    this.old = old;
  }


  @Override
  public boolean equals(java.lang.Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    TemplateSummaryDiffNotificationEndpoints templateSummaryDiffNotificationEndpoints = (TemplateSummaryDiffNotificationEndpoints) o;
    return Objects.equals(this.kind, templateSummaryDiffNotificationEndpoints.kind) &&
        Objects.equals(this.stateStatus, templateSummaryDiffNotificationEndpoints.stateStatus) &&
        Objects.equals(this.id, templateSummaryDiffNotificationEndpoints.id) &&
        Objects.equals(this.templateMetaName, templateSummaryDiffNotificationEndpoints.templateMetaName) &&
        Objects.equals(this._new, templateSummaryDiffNotificationEndpoints._new) &&
        Objects.equals(this.old, templateSummaryDiffNotificationEndpoints.old);
  }

  @Override
  public int hashCode() {
    return Objects.hash(kind, stateStatus, id, templateMetaName, _new, old);
  }


  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class TemplateSummaryDiffNotificationEndpoints {\n");
    sb.append("    kind: ").append(toIndentedString(kind)).append("\n");
    sb.append("    stateStatus: ").append(toIndentedString(stateStatus)).append("\n");
    sb.append("    id: ").append(toIndentedString(id)).append("\n");
    sb.append("    templateMetaName: ").append(toIndentedString(templateMetaName)).append("\n");
    sb.append("    _new: ").append(toIndentedString(_new)).append("\n");
    sb.append("    old: ").append(toIndentedString(old)).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(java.lang.Object o) {
    if (o == null) {
      return "null";
    }
    return o.toString().replace("\n", "\n    ");
  }

  public static class TemplateSummary_diff_notificationEndpointsOldAdapter implements JsonDeserializer, JsonSerializer {

    public TemplateSummary_diff_notificationEndpointsOldAdapter() {
    }

    @Override
    public Object deserialize(final JsonElement json, final Type typeOfT, final JsonDeserializationContext context) throws JsonParseException {

      List discriminator = Arrays.asList("type");

      JsonObject jsonObject = json.getAsJsonObject();

      String[] types = discriminator.stream().map(jsonObject::get).filter(Objects::nonNull).map(JsonElement::getAsString).toArray(String[]::new);

      return deserialize(types, jsonObject, context);
    }

    @Override
    public JsonElement serialize(Object object, Type typeOfSrc, JsonSerializationContext context) {

      return context.serialize(object);
    }

    private Object deserialize(final String[] types, final JsonElement json, final JsonDeserializationContext context) {

      if (Arrays.equals(new String[]{ "slack" }, types)) {
        return context.deserialize(json, SlackNotificationEndpoint.class);
      }
      if (Arrays.equals(new String[]{ "pagerduty" }, types)) {
        return context.deserialize(json, PagerDutyNotificationEndpoint.class);
      }
      if (Arrays.equals(new String[]{ "http" }, types)) {
        return context.deserialize(json, HTTPNotificationEndpoint.class);
      }
      if (Arrays.equals(new String[]{ "telegram" }, types)) {
        return context.deserialize(json, TelegramNotificationEndpoint.class);
      }

      return context.deserialize(json, Object.class);
    }
  }
  public static class TemplateSummary_diff_notificationEndpointsNewAdapter implements JsonDeserializer, JsonSerializer {

    public TemplateSummary_diff_notificationEndpointsNewAdapter() {
    }

    @Override
    public Object deserialize(final JsonElement json, final Type typeOfT, final JsonDeserializationContext context) throws JsonParseException {

      List discriminator = Arrays.asList("type");

      JsonObject jsonObject = json.getAsJsonObject();

      String[] types = discriminator.stream().map(jsonObject::get).filter(Objects::nonNull).map(JsonElement::getAsString).toArray(String[]::new);

      return deserialize(types, jsonObject, context);
    }

    @Override
    public JsonElement serialize(Object object, Type typeOfSrc, JsonSerializationContext context) {

      return context.serialize(object);
    }

    private Object deserialize(final String[] types, final JsonElement json, final JsonDeserializationContext context) {

      if (Arrays.equals(new String[]{ "slack" }, types)) {
        return context.deserialize(json, SlackNotificationEndpoint.class);
      }
      if (Arrays.equals(new String[]{ "pagerduty" }, types)) {
        return context.deserialize(json, PagerDutyNotificationEndpoint.class);
      }
      if (Arrays.equals(new String[]{ "http" }, types)) {
        return context.deserialize(json, HTTPNotificationEndpoint.class);
      }
      if (Arrays.equals(new String[]{ "telegram" }, types)) {
        return context.deserialize(json, TelegramNotificationEndpoint.class);
      }

      return context.deserialize(json, Object.class);
    }
  }
}