1 package org
.asamk
.signal
.manager
.api
;
3 import org
.asamk
.signal
.manager
.groups
.GroupId
;
4 import org
.whispersystems
.signalservice
.api
.push
.SignalServiceAddress
;
5 import org
.whispersystems
.signalservice
.api
.util
.InvalidNumberException
;
6 import org
.whispersystems
.signalservice
.api
.util
.PhoneNumberFormatter
;
7 import org
.whispersystems
.signalservice
.api
.util
.UuidUtil
;
11 public abstract class RecipientIdentifier
{
13 public static class NoteToSelf
extends RecipientIdentifier
{
15 public static NoteToSelf INSTANCE
= new NoteToSelf();
17 private NoteToSelf() {
21 public abstract static class Single
extends RecipientIdentifier
{
23 public static Single
fromString(String identifier
, String localNumber
) throws InvalidNumberException
{
24 return UuidUtil
.isUuid(identifier
)
25 ?
new Uuid(UUID
.fromString(identifier
))
26 : new Number(PhoneNumberFormatter
.formatNumber(identifier
, localNumber
));
29 public static Single
fromAddress(SignalServiceAddress address
) {
30 return new Uuid(address
.getUuid());
34 public static class Uuid
extends Single
{
36 public final UUID uuid
;
38 public Uuid(final UUID uuid
) {
43 public boolean equals(final Object o
) {
44 if (this == o
) return true;
45 if (o
== null || getClass() != o
.getClass()) return false;
47 final Uuid uuid1
= (Uuid
) o
;
49 return uuid
.equals(uuid1
.uuid
);
53 public int hashCode() {
54 return uuid
.hashCode();
58 public static class Number
extends Single
{
60 public final String number
;
62 public Number(final String number
) {
67 public boolean equals(final Object o
) {
68 if (this == o
) return true;
69 if (o
== null || getClass() != o
.getClass()) return false;
71 final Number number1
= (Number
) o
;
73 return number
.equals(number1
.number
);
77 public int hashCode() {
78 return number
.hashCode();
82 public static class Group
extends RecipientIdentifier
{
84 public final GroupId groupId
;
86 public Group(final GroupId groupId
) {
87 this.groupId
= groupId
;
91 public boolean equals(final Object o
) {
92 if (this == o
) return true;
93 if (o
== null || getClass() != o
.getClass()) return false;
95 final Group group
= (Group
) o
;
97 return groupId
.equals(group
.groupId
);
101 public int hashCode() {
102 return groupId
.hashCode();