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

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

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

import com.sinch.sdk.core.models.OptionalValue;
import com.sinch.sdk.domains.conversation.models.v1.Agent;
import com.sinch.sdk.domains.conversation.models.v1.ConversationChannel;
import com.sinch.sdk.domains.conversation.models.v1.messages.types.channelspecific.ChannelSpecificMessage;
import java.util.Map;

public class AppMessageImpl implements AppMessage {

  private final OptionalValue message;
  private final OptionalValue> explicitChannelMessage;
  private final OptionalValue>
      explicitChannelOmniMessage;
  private final OptionalValue>
      channelSpecificMessage;
  private final OptionalValue agent;

  public AppMessageImpl(
      OptionalValue message,
      OptionalValue> explicitChannelMessage,
      OptionalValue>
          explicitChannelOmniMessage,
      OptionalValue> channelSpecificMessage,
      OptionalValue agent) {
    this.message = message;
    this.explicitChannelMessage = explicitChannelMessage;
    this.explicitChannelOmniMessage = explicitChannelOmniMessage;
    this.channelSpecificMessage = channelSpecificMessage;
    this.agent = agent;
  }

  public T getBody() {
    return message.orElse(null);
  }

  public OptionalValue body() {
    return message;
  }

  public Map getExplicitChannelMessage() {
    return explicitChannelMessage.orElse(null);
  }

  public OptionalValue> explicitChannelMessage() {
    return explicitChannelMessage;
  }

  public Map
      getExplicitChannelOmniMessage() {
    return explicitChannelOmniMessage.orElse(null);
  }

  public OptionalValue>
      explicitChannelOmniMessage() {
    return explicitChannelOmniMessage;
  }

  public Map getChannelSpecificMessage() {
    return channelSpecificMessage.orElse(null);
  }

  public OptionalValue> channelSpecificMessage() {
    return channelSpecificMessage;
  }

  public Agent getAgent() {
    return agent.orElse(null);
  }

  public OptionalValue agent() {
    return agent;
  }

  @Override
  public String toString() {
    return "AppMessageImpl{"
        + "message="
        + message
        + ", explicitChannelMessage="
        + explicitChannelMessage
        + ", explicitChannelOmniMessage="
        + explicitChannelOmniMessage
        + ", channelSpecificMessage="
        + channelSpecificMessage
        + ", agent="
        + agent
        + '}';
  }

  /** Dedicated Builder */
  static class Builder implements AppMessage.Builder {

    OptionalValue message = OptionalValue.empty();
    OptionalValue> explicitChannelMessage = OptionalValue.empty();
    OptionalValue>
        explicitChannelOmniMessage = OptionalValue.empty();
    OptionalValue> channelSpecificMessage =
        OptionalValue.empty();
    OptionalValue agent = OptionalValue.empty();

    public Builder setBody(T message) {
      this.message = OptionalValue.of(message);
      return this;
    }

    public Builder setExplicitChannelMessage(
        Map explicitChannelMessage) {
      this.explicitChannelMessage = OptionalValue.of(explicitChannelMessage);
      return this;
    }

    public Builder setExplicitChannelOmniMessage(
        Map
            explicitChannelOmniMessage) {
      this.explicitChannelOmniMessage = OptionalValue.of(explicitChannelOmniMessage);
      return this;
    }

    public Builder setChannelSpecificMessage(
        Map channelSpecificMessage) {
      this.channelSpecificMessage = OptionalValue.of(channelSpecificMessage);
      return this;
    }

    public Builder setAgent(Agent agent) {
      this.agent = OptionalValue.of(agent);
      return this;
    }

    public AppMessage build() {
      return new AppMessageImpl<>(
          message,
          explicitChannelMessage,
          explicitChannelOmniMessage,
          channelSpecificMessage,
          agent);
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy