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

com.sinch.sdk.domains.conversation.models.v1.ChannelIdentityImpl Maven / Gradle / Ivy

There is a newer version: 1.4.0
Show newest version
package com.sinch.sdk.domains.conversation.models.v1;

import com.fasterxml.jackson.annotation.JsonFilter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
import com.sinch.sdk.core.models.OptionalValue;
import java.util.Objects;

@JsonPropertyOrder({
  ChannelIdentityImpl.JSON_PROPERTY_APP_ID,
  ChannelIdentityImpl.JSON_PROPERTY_CHANNEL,
  ChannelIdentityImpl.JSON_PROPERTY_IDENTITY
})
@JsonFilter("uninitializedFilter")
@JsonInclude(value = JsonInclude.Include.CUSTOM)
public class ChannelIdentityImpl implements ChannelIdentity {
  private static final long serialVersionUID = 1L;

  public static final String JSON_PROPERTY_APP_ID = "app_id";

  private OptionalValue appId;

  public static final String JSON_PROPERTY_CHANNEL = "channel";

  private OptionalValue channel;

  public static final String JSON_PROPERTY_IDENTITY = "identity";

  private OptionalValue identity;

  public ChannelIdentityImpl() {}

  protected ChannelIdentityImpl(
      OptionalValue appId,
      OptionalValue channel,
      OptionalValue identity) {
    this.appId = appId;
    this.channel = channel;
    this.identity = identity;
  }

  @JsonIgnore
  public String getAppId() {
    return appId.orElse(null);
  }

  @JsonProperty(JSON_PROPERTY_APP_ID)
  @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
  public OptionalValue appId() {
    return appId;
  }

  @JsonIgnore
  public ConversationChannel getChannel() {
    return channel.orElse(null);
  }

  @JsonProperty(JSON_PROPERTY_CHANNEL)
  @JsonInclude(value = JsonInclude.Include.ALWAYS)
  public OptionalValue channel() {
    return channel;
  }

  @JsonIgnore
  public String getIdentity() {
    return identity.orElse(null);
  }

  @JsonProperty(JSON_PROPERTY_IDENTITY)
  @JsonInclude(value = JsonInclude.Include.ALWAYS)
  public OptionalValue identity() {
    return identity;
  }

  /** Return true if this ChannelIdentity object is equal to o. */
  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    ChannelIdentityImpl channelIdentity = (ChannelIdentityImpl) o;
    return Objects.equals(this.appId, channelIdentity.appId)
        && Objects.equals(this.channel, channelIdentity.channel)
        && Objects.equals(this.identity, channelIdentity.identity);
  }

  @Override
  public int hashCode() {
    return Objects.hash(appId, channel, identity);
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class ChannelIdentityImpl {\n");
    sb.append("    appId: ").append(toIndentedString(appId)).append("\n");
    sb.append("    channel: ").append(toIndentedString(channel)).append("\n");
    sb.append("    identity: ").append(toIndentedString(identity)).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    ");
  }

  @JsonPOJOBuilder(withPrefix = "set")
  static class Builder implements ChannelIdentity.Builder {
    OptionalValue appId = OptionalValue.empty();
    OptionalValue channel = OptionalValue.empty();
    OptionalValue identity = OptionalValue.empty();

    @JsonProperty(JSON_PROPERTY_APP_ID)
    public Builder setAppId(String appId) {
      this.appId = OptionalValue.of(appId);
      return this;
    }

    @JsonProperty(JSON_PROPERTY_CHANNEL)
    public Builder setChannel(ConversationChannel channel) {
      this.channel = OptionalValue.of(channel);
      return this;
    }

    @JsonProperty(JSON_PROPERTY_IDENTITY)
    public Builder setIdentity(String identity) {
      this.identity = OptionalValue.of(identity);
      return this;
    }

    public ChannelIdentity build() {
      return new ChannelIdentityImpl(appId, channel, identity);
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy