package org.whispersystems.textsecure.api.messages; import org.whispersystems.libaxolotl.util.guava.Optional; import java.util.List; public class TextSecureMessage { private final long timestamp; private final Optional> attachments; private final Optional body; private final Optional group; private final boolean secure; private final boolean endSession; public TextSecureMessage(long timestamp, String body) { this(timestamp, null, body); } public TextSecureMessage(long timestamp, List attachments, String body) { this(timestamp, null, attachments, body); } public TextSecureMessage(long timestamp, TextSecureGroup group, List attachments, String body) { this(timestamp, group, attachments, body, true, false); } public TextSecureMessage(long timestamp, TextSecureGroup group, List attachments, String body, boolean secure, boolean endSession) { this.timestamp = timestamp; this.body = Optional.fromNullable(body); this.group = Optional.fromNullable(group); this.secure = secure; this.endSession = endSession; if (attachments != null && !attachments.isEmpty()) { this.attachments = Optional.of(attachments); } else { this.attachments = Optional.absent(); } } public long getTimestamp() { return timestamp; } public Optional> getAttachments() { return attachments; } public Optional getBody() { return body; } public Optional getGroupInfo() { return group; } public boolean isSecure() { return secure; } public boolean isEndSession() { return endSession; } public boolean isGroupUpdate() { return group.isPresent() && group.get().getType() != TextSecureGroup.Type.DELIVER; } }