com.amazonaws.services.pinpoint.model.MessageRequest Maven / Gradle / Ivy
/*
* Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package com.amazonaws.services.pinpoint.model;
import java.io.Serializable;
/**
* Send message request.
*/
public class MessageRequest implements Serializable {
/**
* A map of destination addresses, with the address as the key(Email
* address, phone number or push token) and the Address Configuration as the
* value.
*/
private java.util.Map addresses;
/**
* A map of custom attributes to attributes to be attached to the message.
* This payload is added to the push notification's 'data.pinpoint' object
* or added to the email/sms delivery receipt event attributes.
*/
private java.util.Map context;
/**
* A map of destination addresses, with the address as the key(Email
* address, phone number or push token) and the Address Configuration as the
* value.
*/
private java.util.Map endpoints;
/**
* Message configuration.
*/
private DirectMessageConfiguration messageConfiguration;
/**
* A map of destination addresses, with the address as the key(Email
* address, phone number or push token) and the Address Configuration as the
* value.
*
* @return A map of destination addresses, with the address as the key(Email
* address, phone number or push token) and the Address
* Configuration as the value.
*/
public java.util.Map getAddresses() {
return addresses;
}
/**
* A map of destination addresses, with the address as the key(Email
* address, phone number or push token) and the Address Configuration as the
* value.
*
* @param addresses A map of destination addresses, with the address as the
* key(Email address, phone number or push token) and the Address
* Configuration as the value.
*/
public void setAddresses(java.util.Map addresses) {
this.addresses = addresses;
}
/**
* A map of destination addresses, with the address as the key(Email
* address, phone number or push token) and the Address Configuration as the
* value.
*
* Returns a reference to this object so that method calls can be chained
* together.
*
* @param addresses A map of destination addresses, with the address as the
* key(Email address, phone number or push token) and the Address
* Configuration as the value.
* @return A reference to this updated object so that method calls can be
* chained together.
*/
public MessageRequest withAddresses(java.util.Map addresses) {
this.addresses = addresses;
return this;
}
/**
* A map of destination addresses, with the address as the key(Email
* address, phone number or push token) and the Address Configuration as the
* value.
*
* The method adds a new key-value pair into Addresses parameter, and
* returns a reference to this object so that method calls can be chained
* together.
*
* @param key The key of the entry to be added into Addresses.
* @param value The corresponding value of the entry to be added into
* Addresses.
* @return A reference to this updated object so that method calls can be
* chained together.
*/
public MessageRequest addAddressesEntry(String key, AddressConfiguration value) {
if (null == this.addresses) {
this.addresses = new java.util.HashMap();
}
if (this.addresses.containsKey(key))
throw new IllegalArgumentException("Duplicated keys (" + key.toString()
+ ") are provided.");
this.addresses.put(key, value);
return this;
}
/**
* Removes all the entries added into Addresses.
*
* Returns a reference to this object so that method calls can be chained
* together.
*/
public MessageRequest clearAddressesEntries() {
this.addresses = null;
return this;
}
/**
* A map of custom attributes to attributes to be attached to the message.
* This payload is added to the push notification's 'data.pinpoint' object
* or added to the email/sms delivery receipt event attributes.
*
* @return A map of custom attributes to attributes to be attached to the
* message. This payload is added to the push notification's
* 'data.pinpoint' object or added to the email/sms delivery receipt
* event attributes.
*/
public java.util.Map getContext() {
return context;
}
/**
* A map of custom attributes to attributes to be attached to the message.
* This payload is added to the push notification's 'data.pinpoint' object
* or added to the email/sms delivery receipt event attributes.
*
* @param context A map of custom attributes to attributes to be attached to
* the message. This payload is added to the push notification's
* 'data.pinpoint' object or added to the email/sms delivery
* receipt event attributes.
*/
public void setContext(java.util.Map context) {
this.context = context;
}
/**
* A map of custom attributes to attributes to be attached to the message.
* This payload is added to the push notification's 'data.pinpoint' object
* or added to the email/sms delivery receipt event attributes.
*
* Returns a reference to this object so that method calls can be chained
* together.
*
* @param context A map of custom attributes to attributes to be attached to
* the message. This payload is added to the push notification's
* 'data.pinpoint' object or added to the email/sms delivery
* receipt event attributes.
* @return A reference to this updated object so that method calls can be
* chained together.
*/
public MessageRequest withContext(java.util.Map context) {
this.context = context;
return this;
}
/**
* A map of custom attributes to attributes to be attached to the message.
* This payload is added to the push notification's 'data.pinpoint' object
* or added to the email/sms delivery receipt event attributes.
*
* The method adds a new key-value pair into Context parameter, and returns
* a reference to this object so that method calls can be chained together.
*
* @param key The key of the entry to be added into Context.
* @param value The corresponding value of the entry to be added into
* Context.
* @return A reference to this updated object so that method calls can be
* chained together.
*/
public MessageRequest addContextEntry(String key, String value) {
if (null == this.context) {
this.context = new java.util.HashMap();
}
if (this.context.containsKey(key))
throw new IllegalArgumentException("Duplicated keys (" + key.toString()
+ ") are provided.");
this.context.put(key, value);
return this;
}
/**
* Removes all the entries added into Context.
*
* Returns a reference to this object so that method calls can be chained
* together.
*/
public MessageRequest clearContextEntries() {
this.context = null;
return this;
}
/**
* A map of destination addresses, with the address as the key(Email
* address, phone number or push token) and the Address Configuration as the
* value.
*
* @return A map of destination addresses, with the address as the key(Email
* address, phone number or push token) and the Address
* Configuration as the value.
*/
public java.util.Map getEndpoints() {
return endpoints;
}
/**
* A map of destination addresses, with the address as the key(Email
* address, phone number or push token) and the Address Configuration as the
* value.
*
* @param endpoints A map of destination addresses, with the address as the
* key(Email address, phone number or push token) and the Address
* Configuration as the value.
*/
public void setEndpoints(java.util.Map endpoints) {
this.endpoints = endpoints;
}
/**
* A map of destination addresses, with the address as the key(Email
* address, phone number or push token) and the Address Configuration as the
* value.
*
* Returns a reference to this object so that method calls can be chained
* together.
*
* @param endpoints A map of destination addresses, with the address as the
* key(Email address, phone number or push token) and the Address
* Configuration as the value.
* @return A reference to this updated object so that method calls can be
* chained together.
*/
public MessageRequest withEndpoints(java.util.Map endpoints) {
this.endpoints = endpoints;
return this;
}
/**
* A map of destination addresses, with the address as the key(Email
* address, phone number or push token) and the Address Configuration as the
* value.
*
* The method adds a new key-value pair into Endpoints parameter, and
* returns a reference to this object so that method calls can be chained
* together.
*
* @param key The key of the entry to be added into Endpoints.
* @param value The corresponding value of the entry to be added into
* Endpoints.
* @return A reference to this updated object so that method calls can be
* chained together.
*/
public MessageRequest addEndpointsEntry(String key, EndpointSendConfiguration value) {
if (null == this.endpoints) {
this.endpoints = new java.util.HashMap();
}
if (this.endpoints.containsKey(key))
throw new IllegalArgumentException("Duplicated keys (" + key.toString()
+ ") are provided.");
this.endpoints.put(key, value);
return this;
}
/**
* Removes all the entries added into Endpoints.
*
* Returns a reference to this object so that method calls can be chained
* together.
*/
public MessageRequest clearEndpointsEntries() {
this.endpoints = null;
return this;
}
/**
* Message configuration.
*
* @return Message configuration.
*/
public DirectMessageConfiguration getMessageConfiguration() {
return messageConfiguration;
}
/**
* Message configuration.
*
* @param messageConfiguration Message configuration.
*/
public void setMessageConfiguration(DirectMessageConfiguration messageConfiguration) {
this.messageConfiguration = messageConfiguration;
}
/**
* Message configuration.
*
* Returns a reference to this object so that method calls can be chained
* together.
*
* @param messageConfiguration Message configuration.
* @return A reference to this updated object so that method calls can be
* chained together.
*/
public MessageRequest withMessageConfiguration(DirectMessageConfiguration messageConfiguration) {
this.messageConfiguration = messageConfiguration;
return this;
}
/**
* Returns a string representation of this object; useful for testing and
* debugging.
*
* @return A string representation of this object.
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
if (getAddresses() != null)
sb.append("Addresses: " + getAddresses() + ",");
if (getContext() != null)
sb.append("Context: " + getContext() + ",");
if (getEndpoints() != null)
sb.append("Endpoints: " + getEndpoints() + ",");
if (getMessageConfiguration() != null)
sb.append("MessageConfiguration: " + getMessageConfiguration());
sb.append("}");
return sb.toString();
}
@Override
public int hashCode() {
final int prime = 31;
int hashCode = 1;
hashCode = prime * hashCode + ((getAddresses() == null) ? 0 : getAddresses().hashCode());
hashCode = prime * hashCode + ((getContext() == null) ? 0 : getContext().hashCode());
hashCode = prime * hashCode + ((getEndpoints() == null) ? 0 : getEndpoints().hashCode());
hashCode = prime * hashCode
+ ((getMessageConfiguration() == null) ? 0 : getMessageConfiguration().hashCode());
return hashCode;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (obj instanceof MessageRequest == false)
return false;
MessageRequest other = (MessageRequest) obj;
if (other.getAddresses() == null ^ this.getAddresses() == null)
return false;
if (other.getAddresses() != null
&& other.getAddresses().equals(this.getAddresses()) == false)
return false;
if (other.getContext() == null ^ this.getContext() == null)
return false;
if (other.getContext() != null && other.getContext().equals(this.getContext()) == false)
return false;
if (other.getEndpoints() == null ^ this.getEndpoints() == null)
return false;
if (other.getEndpoints() != null
&& other.getEndpoints().equals(this.getEndpoints()) == false)
return false;
if (other.getMessageConfiguration() == null ^ this.getMessageConfiguration() == null)
return false;
if (other.getMessageConfiguration() != null
&& other.getMessageConfiguration().equals(this.getMessageConfiguration()) == false)
return false;
return true;
}
}