If you think the Android project SymptomManagement listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package com.coursera.capstone.data;
//fromwww.java2s.comimport java.io.Serializable;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
publicfinalclass Message implements Serializable {
privatefinal String collapseKey;
privatefinal Boolean delayWhileIdle;
privatefinalInteger timeToLive;
privatefinal Map<String, String> data;
privatefinal Boolean dryRun;
privatefinal String restrictedPackageName;
publicstaticfinalclass Builder {
privatefinal Map<String, String> data;
// optional parameters
private String collapseKey;
private Boolean delayWhileIdle;
privateInteger timeToLive;
private Boolean dryRun;
private String restrictedPackageName;
public Builder() {
this.data = new LinkedHashMap<String, String>();
}
public Builder collapseKey(String value) {
collapseKey = value;
returnthis;
}
public Builder delayWhileIdle(boolean value) {
delayWhileIdle = value;
returnthis;
}
/**
* Sets the time to live, in seconds.
*/public Builder timeToLive(int value) {
timeToLive = value;
returnthis;
}
/**
* Adds a key/value pair to the payload data.
*/public Builder addData(String key, String value) {
data.put(key, value);
returnthis;
}
/**
* Sets the dryRun property (default value is {@literal false}).
*/public Builder dryRun(boolean value) {
dryRun = value;
returnthis;
}
/**
* Sets the restrictedPackageName property.
*/public Builder restrictedPackageName(String value) {
restrictedPackageName = value;
returnthis;
}
public Message build() {
returnnew Message(this);
}
}
private Message(Builder builder) {
collapseKey = builder.collapseKey;
delayWhileIdle = builder.delayWhileIdle;
data = Collections.unmodifiableMap(builder.data);
timeToLive = builder.timeToLive;
dryRun = builder.dryRun;
restrictedPackageName = builder.restrictedPackageName;
}
/**
* Gets the collapse key.
*/public String getCollapseKey() {
return collapseKey;
}
/**
* Gets the delayWhileIdle flag.
*/public Boolean isDelayWhileIdle() {
return delayWhileIdle;
}
/**
* Gets the time to live (in seconds).
*/publicInteger getTimeToLive() {
return timeToLive;
}
/**
* Gets the dryRun flag.
*/public Boolean isDryRun() {
return dryRun;
}
/**
* Gets the restricted package name.
*/public String getRestrictedPackageName() {
return restrictedPackageName;
}
/**
* Gets the payload data, which is immutable.
*/public Map<String, String> getData() {
return data;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder("Message(");
if (collapseKey != null) {
builder.append("collapseKey=").append(collapseKey).append(", ");
}
if (timeToLive != null) {
builder.append("timeToLive=").append(timeToLive).append(", ");
}
if (delayWhileIdle != null) {
builder.append("delayWhileIdle=").append(delayWhileIdle).append(", ");
}
if (dryRun != null) {
builder.append("dryRun=").append(dryRun).append(", ");
}
if (restrictedPackageName != null) {
builder.append("restrictedPackageName=").append(restrictedPackageName).append(", ");
}
if (!data.isEmpty()) {
builder.append("data: {");
for (Map.Entry<String, String> entry : data.entrySet()) {
builder.append(entry.getKey()).append("=").append(entry.getValue())
.append(",");
}
builder.delete(builder.length() - 1, builder.length());
builder.append("}");
}
if (builder.charAt(builder.length() - 1) == ' ') {
builder.delete(builder.length() - 2, builder.length());
}
builder.append(")");
return builder.toString();
}
}