org.whispersystems.signalservice.api.messages.multidevice.SignalServiceSyncMessage Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of signal-service-java Show documentation
Show all versions of signal-service-java Show documentation
Signal Service communication library for Java
/**
* Copyright (C) 2014-2016 Open Whisper Systems
*
* Licensed according to the LICENSE file in this repository.
*/
package org.whispersystems.signalservice.api.messages.multidevice;
import org.whispersystems.libsignal.util.guava.Optional;
import org.whispersystems.signalservice.api.messages.SignalServiceAttachment;
import java.util.LinkedList;
import java.util.List;
public class SignalServiceSyncMessage {
private final Optional sent;
private final Optional contacts;
private final Optional groups;
private final Optional blockedList;
private final Optional request;
private final Optional> reads;
private SignalServiceSyncMessage(Optional sent,
Optional contacts,
Optional groups,
Optional blockedList,
Optional request,
Optional> reads)
{
this.sent = sent;
this.contacts = contacts;
this.groups = groups;
this.blockedList = blockedList;
this.request = request;
this.reads = reads;
}
public static SignalServiceSyncMessage forSentTranscript(SentTranscriptMessage sent) {
return new SignalServiceSyncMessage(Optional.of(sent),
Optional.absent(),
Optional.absent(),
Optional.absent(),
Optional.absent(),
Optional.>absent());
}
public static SignalServiceSyncMessage forContacts(SignalServiceAttachment contacts) {
return new SignalServiceSyncMessage(Optional.absent(),
Optional.of(contacts),
Optional.absent(),
Optional.absent(),
Optional.absent(),
Optional.>absent());
}
public static SignalServiceSyncMessage forGroups(SignalServiceAttachment groups) {
return new SignalServiceSyncMessage(Optional.absent(),
Optional.absent(),
Optional.of(groups),
Optional.absent(),
Optional.absent(),
Optional.>absent());
}
public static SignalServiceSyncMessage forRequest(RequestMessage request) {
return new SignalServiceSyncMessage(Optional.absent(),
Optional.absent(),
Optional.absent(),
Optional.absent(),
Optional.of(request),
Optional.>absent());
}
public static SignalServiceSyncMessage forRead(List reads) {
return new SignalServiceSyncMessage(Optional.absent(),
Optional.absent(),
Optional.absent(),
Optional.absent(),
Optional.absent(),
Optional.of(reads));
}
public static SignalServiceSyncMessage forRead(ReadMessage read) {
List reads = new LinkedList<>();
reads.add(read);
return new SignalServiceSyncMessage(Optional.absent(),
Optional.absent(),
Optional.absent(),
Optional.absent(),
Optional.absent(),
Optional.of(reads));
}
public static SignalServiceSyncMessage forBlocked(BlockedListMessage blocked) {
return new SignalServiceSyncMessage(Optional.absent(),
Optional.absent(),
Optional.absent(),
Optional.of(blocked),
Optional.absent(),
Optional.>absent());
}
public static SignalServiceSyncMessage empty() {
return new SignalServiceSyncMessage(Optional.absent(),
Optional.absent(),
Optional.absent(),
Optional.absent(),
Optional.absent(),
Optional.>absent());
}
public Optional getSent() {
return sent;
}
public Optional getGroups() {
return groups;
}
public Optional getContacts() {
return contacts;
}
public Optional getRequest() {
return request;
}
public Optional> getRead() {
return reads;
}
public Optional getBlockedList() {
return blockedList;
}
}