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

com.sinch.sdk.domains.conversation.models.v1.messages.ContactMessageImpl 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;

public class ContactMessageImpl implements ContactMessage {

  private final OptionalValue message;

  private final OptionalValue replyTo;

  public ContactMessageImpl(OptionalValue message, OptionalValue replyTo) {
    this.message = message;
    this.replyTo = replyTo;
  }

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

  public OptionalValue body() {
    return message;
  }

  public ReplyTo getReplyTo() {
    return replyTo.orElse(null);
  }

  public OptionalValue replyTo() {
    return replyTo;
  }

  @Override
  public String toString() {
    return "ContactMessageImpl{" + "message=" + message + ", replyTo=" + replyTo + '}';
  }

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

    OptionalValue message = OptionalValue.empty();
    OptionalValue replyTo = OptionalValue.empty();

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

    public Builder setReplyTo(ReplyTo replyTo) {
      this.replyTo = OptionalValue.of(replyTo);
      return this;
    }

    public ContactMessage build() {
      return new ContactMessageImpl<>(message, replyTo);
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy