Java Code Examples for org.whispersystems.libsignal.util.guava.Optional#fromNullable()
The following examples show how to use
org.whispersystems.libsignal.util.guava.Optional#fromNullable() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SignalServiceAttachmentPointer.java From bcm-android with GNU General Public License v3.0 | 6 votes |
public SignalServiceAttachmentPointer(long id, String contentType, byte[] key, String relay, Optional<Integer> size, Optional<byte[]> preview, Optional<byte[]> digest, Optional<String> fileName, boolean voiceNote, Optional<String> url) { super(contentType, ""); this.id = id; this.key = key; this.relay = Optional.fromNullable(relay); this.size = size; this.preview = preview; this.digest = digest; this.fileName = fileName; this.voiceNote = voiceNote; this.url = url; }
Example 2
Source File: Recipient.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
public @NonNull Optional<String> getUsername() { if (FeatureFlags.usernames()) { return Optional.fromNullable(username); } else { return Optional.absent(); } }
Example 3
Source File: SignalServiceContent.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
private SignalServiceContent(SignalServiceDataMessage message, SignalServiceAddress sender, int senderDevice, long timestamp, long serverTimestamp, boolean needsReceipt, SignalServiceContentProto serializedState) { this.sender = sender; this.senderDevice = senderDevice; this.timestamp = timestamp; this.serverTimestamp = serverTimestamp; this.needsReceipt = needsReceipt; this.serializedState = serializedState; this.message = Optional.fromNullable(message); this.synchronizeMessage = Optional.absent(); this.callMessage = Optional.absent(); this.readMessage = Optional.absent(); this.typingMessage = Optional.absent(); }
Example 4
Source File: DeviceGroupsInputStream.java From bcm-android with GNU General Public License v3.0 | 5 votes |
public DeviceGroup read() throws IOException { long detailsLength = readRawVarint32(); byte[] detailsSerialized = new byte[(int)detailsLength]; Util.readFully(in, detailsSerialized); SignalServiceProtos.GroupDetails details = SignalServiceProtos.GroupDetails.parseFrom(detailsSerialized); if (!details.hasId()) { throw new IOException("ID missing on group record!"); } byte[] id = details.getId().toByteArray(); Optional<String> name = Optional.fromNullable(details.getName()); List<String> members = details.getMembersList(); Optional<SignalServiceAttachmentStream> avatar = Optional.absent(); boolean active = details.getActive(); if (details.hasAvatar()) { long avatarLength = details.getAvatar().getLength(); InputStream avatarStream = new ChunkedInputStream.LimitedInputStream(in, avatarLength); String avatarContentType = details.getAvatar().getContentType(); avatar = Optional.of(new SignalServiceAttachmentStream(avatarStream, avatarContentType, avatarLength, Optional.<String>absent(), false, "",null)); } return new DeviceGroup(id, name, members, avatar, active); }
Example 5
Source File: SignalServiceCallMessage.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
public static SignalServiceCallMessage forHangup(HangupMessage hangupMessage, boolean isMultiRing, Integer destinationDeviceId) { return new SignalServiceCallMessage(Optional.absent(), Optional.absent(), Optional.absent(), Optional.of(hangupMessage), Optional.absent(), isMultiRing, Optional.fromNullable(destinationDeviceId)); }
Example 6
Source File: SignalServiceAddressProtobufSerializerTest.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
@Test public void serialize_and_deserialize_both_address() { SignalServiceAddress address = new SignalServiceAddress(Optional.fromNullable(UUID.randomUUID()), Optional.of("+15552345678"), Optional.<String>absent()); AddressProto addressProto = org.whispersystems.signalservice.internal.serialize.SignalServiceAddressProtobufSerializer.toProtobuf(address); SignalServiceAddress deserialized = org.whispersystems.signalservice.internal.serialize.SignalServiceAddressProtobufSerializer.fromProtobuf(addressProto); assertEquals(address, deserialized); }
Example 7
Source File: SignalServiceAddressProtobufSerializerTest.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
@Test public void serialize_and_deserialize_uuid_address() { SignalServiceAddress address = new SignalServiceAddress(Optional.fromNullable(UUID.randomUUID()), Optional.<String>absent(), Optional.<String>absent()); AddressProto addressProto = org.whispersystems.signalservice.internal.serialize.SignalServiceAddressProtobufSerializer.toProtobuf(address); SignalServiceAddress deserialized = org.whispersystems.signalservice.internal.serialize.SignalServiceAddressProtobufSerializer.fromProtobuf(addressProto); assertEquals(address, deserialized); }
Example 8
Source File: SignalUrl.java From libsignal-service-java with GNU General Public License v3.0 | 5 votes |
public SignalUrl(String url, String hostHeader, TrustStore trustStore, ConnectionSpec connectionSpec) { this.url = url; this.hostHeader = Optional.fromNullable(hostHeader); this.trustStore = trustStore; this.connectionSpec = Optional.fromNullable(connectionSpec); }
Example 9
Source File: TransportOptions.java From mollyim-android with GNU General Public License v3.0 | 4 votes |
public void setSelectedTransport(@Nullable TransportOption transportOption) { this.selectedOption = Optional.fromNullable(transportOption); notifyTransportChangeListeners(); }
Example 10
Source File: DecryptedGroupUtil.java From mollyim-android with GNU General Public License v3.0 | 4 votes |
/** * The UUID of the member that made the change. */ public static Optional<UUID> editorUuid(DecryptedGroupChange change) { return Optional.fromNullable(change != null ? UuidUtil.fromByteStringOrNull(change.getEditor()) : null); }
Example 11
Source File: SharedContact.java From libsignal-service-java with GNU General Public License v3.0 | 4 votes |
public Phone build() { return new Phone(value, type, Optional.fromNullable(label)); }
Example 12
Source File: SignalServiceDataMessage.java From mollyim-android with GNU General Public License v3.0 | 4 votes |
/** * Construct a SignalServiceDataMessage. * * @param timestamp The sent timestamp. * @param group The group information (or null if none). * @param groupV2 The group information (or null if none). * @param attachments The attachments (or null if none). * @param body The message contents. * @param endSession Flag indicating whether this message should close a session. * @param expiresInSeconds Number of seconds in which the message should disappear after being seen. */ SignalServiceDataMessage(long timestamp, SignalServiceGroup group, SignalServiceGroupV2 groupV2, List<SignalServiceAttachment> attachments, String body, boolean endSession, int expiresInSeconds, boolean expirationUpdate, byte[] profileKey, boolean profileKeyUpdate, Quote quote, List<SharedContact> sharedContacts, List<Preview> previews, Sticker sticker, boolean viewOnce, Reaction reaction, RemoteDelete remoteDelete) { try { this.group = SignalServiceGroupContext.createOptional(group, groupV2); } catch (InvalidMessageException e) { throw new AssertionError(e); } this.timestamp = timestamp; this.body = OptionalUtil.absentIfEmpty(body); this.endSession = endSession; this.expiresInSeconds = expiresInSeconds; this.expirationUpdate = expirationUpdate; this.profileKey = Optional.fromNullable(profileKey); this.profileKeyUpdate = profileKeyUpdate; this.quote = Optional.fromNullable(quote); this.sticker = Optional.fromNullable(sticker); this.viewOnce = viewOnce; this.reaction = Optional.fromNullable(reaction); this.remoteDelete = Optional.fromNullable(remoteDelete); if (attachments != null && !attachments.isEmpty()) { this.attachments = Optional.of(attachments); } else { this.attachments = Optional.absent(); } if (sharedContacts != null && !sharedContacts.isEmpty()) { this.contacts = Optional.of(sharedContacts); } else { this.contacts = Optional.absent(); } if (previews != null && !previews.isEmpty()) { this.previews = Optional.of(previews); } else { this.previews = Optional.absent(); } }
Example 13
Source File: Recipient.java From mollyim-android with GNU General Public License v3.0 | 4 votes |
public @NonNull Optional<GroupId> getGroupId() { return Optional.fromNullable(groupId); }
Example 14
Source File: GroupV1ConflictMerger.java From mollyim-android with GNU General Public License v3.0 | 4 votes |
@Override public @NonNull Optional<SignalGroupV1Record> getMatching(@NonNull SignalGroupV1Record record) { return Optional.fromNullable(localByGroupId.get(GroupId.v1orThrow(record.getGroupId()))); }
Example 15
Source File: Slide.java From mollyim-android with GNU General Public License v3.0 | 4 votes |
@NonNull public Optional<String> getFileName() { return Optional.fromNullable(attachment.getFileName()); }
Example 16
Source File: SharedContact.java From mollyim-android with GNU General Public License v3.0 | 4 votes |
public Phone build() { return new Phone(value, type, Optional.fromNullable(label)); }
Example 17
Source File: MmsSmsDatabase.java From Silence with GNU General Public License v3.0 | 4 votes |
public Reader(Cursor cursor, @Nullable MasterSecret masterSecret) { this.cursor = cursor; this.masterSecret = Optional.fromNullable(masterSecret); }
Example 18
Source File: SignalServiceContent.java From bcm-android with GNU General Public License v3.0 | 4 votes |
public SignalServiceContent(SignalServiceSyncMessage synchronizeMessage) { this.message = Optional.absent(); this.synchronizeMessage = Optional.fromNullable(synchronizeMessage); this.callMessage = Optional.absent(); this.readMessage = Optional.absent(); }
Example 19
Source File: Recipient.java From mollyim-android with GNU General Public License v3.0 | 4 votes |
public @NonNull Optional<String> getE164() { return Optional.fromNullable(e164); }
Example 20
Source File: EarlyMessageCache.java From mollyim-android with GNU General Public License v3.0 | 2 votes |
/** * Returns and removes any content that is dependent on the provided message id. * @param sender The sender of the message in question. * @param sentTimestamp The sent timestamp of the message in question. */ public Optional<List<SignalServiceContent>> retrieve(@NonNull RecipientId sender, long sentTimestamp) { return Optional.fromNullable(cache.remove(new MessageId(sender, sentTimestamp))); }